Esempio n. 1
0
        private static ExpirationHint GetExpirationHint(Dependencies.CacheDependency cacheDependency, AggregateExpirationHint aggregateHint)
        {
            if (cacheDependency == null)
            {
                return(null);
            }
            ExpirationHint expirationHint = null;

            if (cacheDependency is Dependencies.KeyDependency)
            {
                var dependency = cacheDependency as Dependencies.KeyDependency;
                expirationHint = new KeyDependency(dependency.CacheKeys, new DateTime(dependency.StartAfterTicks));
                aggregateHint.Add(expirationHint);
            }
            else if (cacheDependency is Dependencies.FileDependency)
            {
                var dependency2 = cacheDependency as Dependencies.FileDependency;
                expirationHint = new FileDependency(dependency2.fileNames, new DateTime(dependency2.StartAfterTicks));
                aggregateHint.Add(expirationHint);
            }
            if (aggregateHint.Hints.Length == 0)
            {
                return(null);
            }
            if (aggregateHint.Hints.Length == 1)
            {
                return(aggregateHint.Hints[0]);
            }
            return(aggregateHint);
        }
Esempio n. 2
0
        public static ExpirationHint GetExpirationHint(Dependencies.CacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration)
        {
            ExpirationHint expirationHint = GetExpirationHint(absoluteExpiration, slidingExpiration);

            if (expirationHint == null)
            {
                return(GetExpirationHint(dependency));
            }
            ExpirationHint eh = GetExpirationHint(dependency);

            if (eh == null)
            {
                return(expirationHint);
            }
            AggregateExpirationHint hint3 = null;

            if (eh is AggregateExpirationHint)
            {
                hint3 = eh as AggregateExpirationHint;
                hint3.Add(expirationHint);
                return(hint3);
            }
            hint3 = new AggregateExpirationHint();
            hint3.Add(expirationHint);
            hint3.Add(eh);
            return(hint3);
        }
Esempio n. 3
0
 /// <summary>
 /// Adiciona uma nova dependencia para a dependencia informada.
 /// </summary>
 /// <param name="cacheDependency"></param>
 /// <param name="newDependency"></param>
 private static void AddToDependency(ref Dependencies.CacheDependency cacheDependency, Dependencies.CacheDependency newDependency)
 {
     if (newDependency != null)
     {
         if (cacheDependency == null)
         {
             cacheDependency = new Dependencies.CacheDependency();
         }
         cacheDependency.Dependencies.Add(newDependency);
     }
 }
Esempio n. 4
0
 public static Dependencies.CacheDependency GetCacheDependency(ExpirationHint hint, out DateTime absoluteExpiration, out TimeSpan slidingExpiration)
 {
     Dependencies.CacheDependency cacheDependency = null;
     absoluteExpiration = DateTime.MaxValue;
     slidingExpiration  = TimeSpan.Zero;
     if (hint != null)
     {
         if (hint is AggregateExpirationHint)
         {
             AggregateExpirationHint hint2 = (AggregateExpirationHint)hint;
             if ((hint2.Hints != null) && (hint2.Hints.Length > 0))
             {
                 foreach (ExpirationHint hint3 in hint2.Hints)
                 {
                     AddToDependency(ref cacheDependency, GetCacheDependency(hint3, out absoluteExpiration, out slidingExpiration));
                 }
             }
             return(cacheDependency);
         }
         if (hint is FixedExpiration)
         {
             absoluteExpiration = ((FixedExpiration)hint).AbsoluteTime;
             return(cacheDependency);
         }
         if (hint is IdleExpiration)
         {
             slidingExpiration = ((IdleExpiration)hint).SlidingTime;
             return(cacheDependency);
         }
         if (hint is KeyDependency)
         {
             var dependency2 = (KeyDependency)hint;
             AddToDependency(ref cacheDependency, new Dependencies.KeyDependency(dependency2.CacheKeys, new DateTime(dependency2.StartAfterTicks)));
             return(cacheDependency);
         }
         if (hint is FileDependency)
         {
             FileDependency dependency3 = (FileDependency)hint;
             AddToDependency(ref cacheDependency, new Dependencies.FileDependency(dependency3.FileNames, new DateTime(dependency3.StartAfterTicks)));
             return(cacheDependency);
         }
         return(cacheDependency);
     }
     return(cacheDependency);
 }
Esempio n. 5
0
        public static ExpirationHint GetExpirationHint(Dependencies.CacheDependency dependency)
        {
            var aggregateHint = new AggregateExpirationHint();

            return(GetExpirationHint(dependency, aggregateHint));
        }