GetHashCode() public method

MemoizerConfiguration hash code format: 5 digits with function ID + 5 digits hash of the rest. 2^31 == 2 147 483 648 == 21474 83648 => max 21474 different Funcs, and 83648 different expiration configurations... This has clearly limitations, but it's OK as a proof-of-concept, I guess - it's fixable :-)
public GetHashCode ( ) : int
return int
        public override bool Equals(object otherObject)
        {
            if (ReferenceEquals(null, otherObject))
            {
                return(false);
            }
            if (ReferenceEquals(this, otherObject))
            {
                return(true);
            }
            MemoizerConfiguration otherMemoizerConfiguration = otherObject as MemoizerConfiguration;

            if (otherMemoizerConfiguration == null)
            {
                return(false);
            }
            return(this.GetHashCode().Equals(otherMemoizerConfiguration.GetHashCode()));
        }
Example #2
0
 public Memoizer(MemoizerConfiguration memoizerConfig, bool shared)
 {
     this.functionToBeMemoized = memoizerConfig.Function;
     this.cacheItemPolicy      = CacheItemPolicyFactory.CreateCacheItemPolicy(memoizerConfig.ExpirationType, memoizerConfig.ExpirationValue, memoizerConfig.ExpirationTimeUnit);
     this.key = memoizerConfig.GetHashCode().ToString();
 }