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 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);
        }