public async Task <ClassificationResponse> Classify(IClassification classificationToRun, DateTime?asOfDate = null) { ClassificationResponse.ClassificationResults ret = ClassificationResponse.ClassificationResults.Unchanged; bool wasEverIncluded = false; bool wasEverExcluded = false; if (null != eventStreamReader) { foreach (IEventContext wrappedEvent in await eventStreamReader.GetEventsWithContext(effectiveDateTime: asOfDate)) { classificationToRun.OnEventRead(wrappedEvent.SequenceNumber, null); if (classificationToRun.HandlesEventType(wrappedEvent.EventInstance.EventTypeName)) { var stepResult = classificationToRun.HandleEvent(wrappedEvent.EventInstance.EventTypeName, wrappedEvent.EventInstance.EventPayload); if (stepResult != ClassificationResponse.ClassificationResults.Unchanged) { // The classification state changed so store it as the current result ret = stepResult; if (ret == ClassificationResponse.ClassificationResults.Include) { wasEverIncluded = true; } if (ret == ClassificationResponse.ClassificationResults.Exclude) { wasEverIncluded = true; } } } // mark the event as handled classificationToRun.MarkEventHandled(wrappedEvent.SequenceNumber); } } return(new ClassificationResponse(ret, classificationToRun.CurrentSequenceNumber, classificationToRun.CurrentAsOfDate, wasEverIncluded, wasEverExcluded, Parameters)); }