protected override void OnDetaching() { if (Messenger != null) { _listener?.Dispose(); } if (AssociatedObject != null) { AssociatedObject.Loaded -= AssociatedObjectLoaded; AssociatedObject.Unloaded -= AssociatedObjectUnloaded; } base.OnDetaching(); }
public void LifeCycleTest() { var listener1Success = false; var eventPublisher = new TestEventPublisher(); var listener1 = new LivetWeakEventListener <EventHandler, EventArgs>( h => new EventHandler(h), h => eventPublisher.EmptyEvent += h, h => eventPublisher.EmptyEvent -= h, (sender, e) => listener1Success = true); //------------------ listener1Success.Is(false); eventPublisher.RaiseEmptyEvent(); listener1Success.Is(true); //------------------ listener1Success = false; listener1.Dispose(); eventPublisher.RaiseEmptyEvent(); listener1Success.Is(false); }
public void LifeCycleTest() { var listener1Success = false; var eventPublisher = new TestEventPublisher(); var listener1 = new LivetWeakEventListener<EventHandler, EventArgs>( h => new EventHandler(h), h => eventPublisher.EmptyEvent += h, h => eventPublisher.EmptyEvent -= h, (sender, e) => listener1Success = true); //------------------ listener1Success.Is(false); eventPublisher.RaiseEmptyEvent(); listener1Success.Is(true); //------------------ listener1Success = false; listener1.Dispose(); eventPublisher.RaiseEmptyEvent(); listener1Success.Is(false); }
private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _listener.Dispose(); } _disposed = true; }