public ICallReturn Invoke(ICallInvocation invocation, GetNextCallHandlerDelegate getNext) { if (cached == null) { cached = new Dictionary <ElementCollection, CachingResult>(); } var args = invocation.Arguments; var key = new ElementCollection(args); CachingResult cachingResult; ICallReturn result = null; if (cached.TryGetValue(key, out cachingResult)) { result = cachingResult.Result; object value; value = cachingResult.Lifetime.GetValue(); if (value != null) //if (cachingResult.Lifetime.GetValue(out value)) { result.ReturnValue = value; } else { cachingResult = null; result = null; } } if (cachingResult == null) { result = getNext()(invocation, getNext); ILifetime lifetime = GetLifetime((MethodInfo)invocation.MethodBase, invocation.Target, result.ReturnValue, cachingData.lifetimeType, cachingData.lifetimeMethodName); cachingResult = new CachingResult(result, lifetime); cached[key] = cachingResult; } return(result); }
public CachingResult(ICallReturn result, ILifetime lifetime) { this.Result = result; this.Lifetime = lifetime; }