///------------------------------------------------------------------------------------------------- /// <summary> /// Registers for attribute changed event. /// </summary> /// <param name="element"> /// The element. /// </param> ///------------------------------------------------------------------------------------------------- public IDisposable RegisterForAttributeChangedEvent(IModelElement element) { if (element is IPropertyChangedNotifier) { DebugContract.Requires(element.Id); _attributedChangedObserversSync.EnterWriteLock(); try { if (_attributedChangedObservers.ContainsKey(element.Id)) { _attributedChangedObservers[element.Id]++; } else { _attributedChangedObservers.Add(element.Id, 1); } return(Disposables.ExecuteOnDispose(() => { _attributedChangedObservers[element.Id]--; if (_attributedChangedObservers[element.Id] == 0) { _attributedChangedObservers.Remove(element.Id); } })); } finally { _attributedChangedObserversSync.ExitWriteLock(); } } return(Disposables.Empty); }
IDisposable ISupportsCalculatedPropertiesTracking.PushCalculatedPropertyTracker(CalculatedProperty tracker) { var ctx = SessionDataContext; if (ctx == null) { return(Disposables.Empty); } if (ctx.Trackers == null) { ctx.Trackers = new Stack <CalculatedProperty>(); } ctx.Trackers.Push(tracker); return(Disposables.ExecuteOnDispose(() => SessionDataContext.Trackers.Pop())); }