public RevertManager(IControlGateway controlGateway, IEventProcessor eventProcessor) { this.controlGateway = controlGateway; this.eventProcessor = eventProcessor; revertIndex = 0; }
/// <summary> /// /// </summary> /// <param name="fileName">file name to save the serialize event</param> /// <param name="controlGateway"></param> /// <param name="isOverwrite">Ovewrite the file if exist</param> public SerializeEventSaver(string fileName, IControlGateway controlGateway, bool isOverwrite = true) { this.fileName = fileName; this.controlGateway = controlGateway; this.isOverwrite = isOverwrite; }
protected Aggregate(long version, IEventProcessor eventProcessor, IControlGateway controlGateway) { Version = version; eventHandlers = new Dictionary <Type, Delegate>(); revertEventHandlers = new Dictionary <Type, Delegate>(); this.eventProcessor = eventProcessor; this.eventProcessor.Subscribe(this); this.controlGateway = controlGateway; }
/// <summary> /// /// </summary> /// <param name="eventSaver">Where the event which will be replay are loaded</param> /// <param name="eventProcessor">The processor which trigger the event throughout /// the whole application</param> /// <param name="gateway"></param> public static void Replay(IEventSaver eventSaver, IEventProcessor eventProcessor, IControlGateway gateway) { IEvent[] eventList = eventSaver.LoadEvents(); //replace with the event list from the file gateway.ReplaceEvents(eventList); //Reset all the state //We must reset all state before we reply the event because //we don't want them the state to be appended to each other eventProcessor.ResetState(); foreach (IEvent eachEvent in eventList) { eventProcessor.Process(eachEvent, true); } }
/// <summary> /// /// </summary> /// <param name="controlGateway">Non null object</param> public static void InjectControlGateway(IControlGateway controlGateway) { Framework.controlGateway = controlGateway; }