protected void OnProtocolEvent(ProtocolEventType eventType, IProtocolStateDifference difference, IProtocolEventData now = null, IProtocolEventData then = null) { var handler = this.ProtocolEvent; if (handler != null) { handler( this, new ProtocolEventArgs() { ProtocolEventType = eventType, ProtocolType = this.ProtocolType as ProtocolType, // Required for serialization. How to get around? StateDifference = difference ?? new ProtocolStateDifference(), Now = now ?? new ProtocolEventData(), Then = then ?? new ProtocolEventData() } ); } }
/// <summary> /// Helper to apply the difference generated from an event. /// </summary> /// <param name="difference">The difference object to apply to the protocols state</param> protected void ApplyProtocolStateDifference(IProtocolStateDifference difference) { if (this.State != null) { // Apply any differences to our state object. this.State.Apply(difference); } }