e79aa3c0ed
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
// <copyright file="DependencyChangeMonitor.cs" company="Microsoft">
|
|
// Copyright (c) 2009 Microsoft Corporation. All rights reserved.
|
|
// </copyright>
|
|
#if USE_MEMORY_CACHE
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Runtime.Caching;
|
|
using System.Web.Util;
|
|
|
|
namespace System.Web.Caching {
|
|
internal sealed class DependencyChangeMonitor: ChangeMonitor, ICacheDependencyChanged {
|
|
private CacheDependency _dependency;
|
|
|
|
public override string UniqueId {
|
|
get {
|
|
return _dependency.GetUniqueID();
|
|
}
|
|
}
|
|
|
|
internal DependencyChangeMonitor(CacheDependency dependency) {
|
|
if (dependency == null) {
|
|
throw new ArgumentNullException("dependency");
|
|
}
|
|
if (!dependency.Use()) {
|
|
throw new InvalidOperationException(
|
|
SR.GetString(SR.Cache_dependency_used_more_that_once));
|
|
}
|
|
_dependency = dependency;
|
|
_dependency.SetCacheDependencyChanged(this);
|
|
if (_dependency.HasChanged) {
|
|
OnChanged(null);
|
|
}
|
|
InitializationComplete();
|
|
}
|
|
|
|
void ICacheDependencyChanged.DependencyChanged(Object sender, EventArgs e) {
|
|
OnChanged(null);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Usage", "CA2215:DisposeMethodsShouldCallBaseClassDispose", Justification="suppressed because fxcop is suffering from despotism")]
|
|
protected override void Dispose(bool disposing) {
|
|
if (disposing) {
|
|
if (_dependency != null) {
|
|
_dependency.DisposeInternal();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|