public virtual LastServiceCallStatus Invoking(Service service, MethodInfo methodInfo) { currentServiceCall = new ServiceCall(service, methodInfo); ServiceCalls matchingHistoryCalls = executionHistory.FindCalls(currentServiceCall); ServiceCalls matchingCurrentServiceCalls = currentServiceCalls.Matching(currentServiceCall); if (matchingHistoryCalls.Count > matchingCurrentServiceCalls.Count) { matchingCurrentServiceCalls.Sort(delegate(ServiceCall x, ServiceCall y) { return(x.CallNumber.CompareTo(y.CallNumber)); }); int currentCallNumberForService = matchingHistoryCalls.Last.CallNumber; ServiceCall matchingCall = matchingHistoryCalls.Find(delegate(ServiceCall obj) { return(obj.CallNumber.Equals(currentCallNumberForService)); }); currentServiceCalls.Add(matchingCall); return(new LastServiceCallStatus(matchingCall.ReturnValue)); } else { currentServiceCall.CallNumber = matchingCurrentServiceCalls.Count; return(new NullLastServiceCallStatus()); } }