Ejemplo n.º 1
0
        protected override void OnDetaching()
        {
            if (Messenger != null)
            {
                _listener?.Dispose();
            }

            if (AssociatedObject != null)
            {
                AssociatedObject.Loaded   -= AssociatedObjectLoaded;
                AssociatedObject.Unloaded -= AssociatedObjectUnloaded;
            }

            base.OnDetaching();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _listener.Dispose();
            }
            _disposed = true;
        }