public static ModelChanged <T> CaptureChangedEvent <T>(this T model, Action <T> modelAction) where T : Aggregate { var tracker = new PropertiesTracker <T>(model); tracker.SaveSnapshot(); modelAction(model); var comparisionResult = tracker.CompareWithCurrentState(); var changedEvent = new ModelChanged <T>(comparisionResult.PropertiesChanged); return(changedEvent); }
public void Dispose() { if (_publishCallback is null) { throw new InvalidOperationException( $"method {nameof(OnCompare)} was not called"); } var comparisionResult = _propertiesTracker.CompareWithCurrentState(); if (comparisionResult.PropertiesChanged.Count > 0) { _publishCallback(comparisionResult); } }