// Generate hash from Method and all args private long GetCacheKey(BridgeContext context) { HashCodeCombiner hasher = new HashCodeCombiner(); hasher.AddObject(context.BridgeUrl); hasher.AddObject(context.ServiceRequest.Method); ComputeHashCode(context.ServiceRequest.Args, hasher); return hasher.CombinedHash; }
// Need to recursively shred dictionaries collections, arrays private void ComputeHashCode(object obj, HashCodeCombiner hasher) { IDictionary dict = obj as IDictionary; if (dict != null) { foreach (object key in dict.Keys) { hasher.AddObject(key); ComputeHashCode(dict[key], hasher); } } else { IEnumerable en = obj as IEnumerable; if ((en != null) && !(obj is string)) { foreach (object o in en) { ComputeHashCode(o, hasher); } } else { hasher.AddObject(obj); } } }