private void SetItemPolicyDependency(CacheItemDependency dependency)
 {
     if (dependency != null)
     {
         if (ItemPolicy.Dependency != null)
         {
             throw new InvalidOperationException(Local.RedefineCacheDependency);
         }
         ItemPolicy.Dependency = dependency;
     }
 }
Exemplo n.º 2
0
        private IEnumerable <DataCacheTag> GetCacheDependency(object tag, CacheItemDependency dependency, ServiceCacheByDispatcher dispatch)
        {
            object value;

            if (dependency == null || (value = dependency(this, dispatch.Registration, tag, dispatch.Values)) == null)
            {
                return(null);
            }
            //
            var names     = (value as string[]);
            var touchable = Settings.Touchable;

            return((touchable != null && names != null ? touchable.MakeDependency(tag, names) : value) as IEnumerable <DataCacheTag>);
        }
 /// <summary>
 /// Adds the data source.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="itemPolicy">The cache command.</param>
 /// <param name="builder">The builder.</param>
 /// <param name="dependency">The dependency.</param>
 public ServiceCacheRegistration(string name, CacheItemPolicy itemPolicy, CacheItemBuilder builder, CacheItemDependency dependency)
     : this(name, itemPolicy, builder)
 {
     SetItemPolicyDependency(dependency);
 }
 /// <summary>
 /// Adds the data source.
 /// </summary>
 /// <param name="name">The key.</param>
 /// <param name="minuteTimeout">The minute timeout.</param>
 /// <param name="builder">The builder.</param>
 /// <param name="dependency">The dependency.</param>
 public ServiceCacheRegistration(string name, int minuteTimeout, CacheItemBuilder builder, CacheItemDependency dependency)
     : this(name, new CacheItemPolicy(minuteTimeout), builder)
 {
     SetItemPolicyDependency(dependency);
 }
 private IEnumerable<DataCacheTag> GetCacheDependency(object tag, CacheItemDependency dependency, ServiceCacheByDispatcher dispatch)
 {
     object value;
     if (dependency == null || (value = dependency(this, dispatch.Registration, tag, dispatch.Values)) == null)
         return null;
     //
     var names = (value as string[]);
     var touchable = Settings.Touchable;
     return ((touchable != null && names != null ? touchable.MakeDependency(tag, names) : value) as IEnumerable<DataCacheTag>);
 }