private bool CompareWithPrevious(CallCounter methodCounter) { //We've already called this method before (and were interrupted by another method). //Additional calls must be formatted as IEnumerable if (methodCounter.ChainCompleted) { return(false); } if (LastMethod != null) { //Same method as last time if (methodCounter == LastMethod) { methodCounter.ConsecutiveCalls++; return(true); } else { //We're being replaced by another method LastMethod.ChainCompleted = true; return(CallNewMethod(methodCounter)); } } else { //First time calling a method return(CallNewMethod(methodCounter)); } }
private bool CallNewMethod(CallCounter methodCounter) { LastMethod = methodCounter; methodCounter.ConsecutiveCalls++; return(true); }