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); }
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); }
public static ExpirationHint GetExpirationHint(Dependencies.CacheDependency dependency) { var aggregateHint = new AggregateExpirationHint(); return(GetExpirationHint(dependency, aggregateHint)); }
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); }
public static ExpirationHint ReadExpHint(CompactReader reader) { ExpirationHintType parent = ExpirationHintType.Parent; parent = (ExpirationHintType)reader.ReadInt16(); switch (parent) { case ExpirationHintType.NULL: return(null); case ExpirationHintType.Parent: return((ExpirationHint)reader.ReadObject()); case ExpirationHintType.FixedExpiration: { FixedExpiration expiration = new FixedExpiration(); expiration.Deserialize(reader); return(expiration); } case ExpirationHintType.FixedIdleExpiration: { FixedIdleExpiration expiration4 = new FixedIdleExpiration(); expiration4.Deserialize(reader); return(expiration4); } case ExpirationHintType.FileDependency: { FileDependency dependency = new FileDependency(); dependency.Deserialize(reader); return(dependency); } case ExpirationHintType.KeyDependency: { KeyDependency dependency2 = new KeyDependency(); dependency2.Deserialize(reader); return(dependency2); } case ExpirationHintType.IdleExpiration: { IdleExpiration expiration5 = new IdleExpiration(); expiration5.Deserialize(reader); return(expiration5); } case ExpirationHintType.AggregateExpirationHint: { AggregateExpirationHint hint2 = new AggregateExpirationHint(); hint2.Deserialize(reader); return(hint2); } case ExpirationHintType.ExtensibleDependency: { ExtensibleDependency dependency8 = new ExtensibleDependency(); return((ExtensibleDependency)reader.ReadObject()); } } return(null); }