Ejemplo n.º 1
0
        /// <summary>
        /// Cleans up the COM object references.
        /// </summary>
        /// <param name="disposing">
        /// <see langword="true"/> if this was called from the
        /// <see cref="IDisposable"/> interface.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _owner             = null;
                _unmappedEventKeys = null;

                if (null != _events)
                {
                    _events.Dispose();
                    _events = null;
                }
            }

            if (null != _connectionPoint)
            {
                if (0 != _connectionCookie)
                {
                    try
                    {
                        _connectionPoint.Unadvise(_connectionCookie);
                        _connectionCookie = 0;
                    }
                    catch { }
                }

                while (Marshal.ReleaseComObject(_connectionPoint) > 0)
                {
                    ;
                }
                _connectionPoint = null;
            }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (_client != null)
            {
                if (_eventSymbols.Count > 0)
                {
                    // unregister events
                    foreach (string symbol in _eventSymbols)
                    {
                        IValueSymbol symb = (IValueSymbol)_symbolLoader.Symbols[symbol];
                        symb.ValueChanged -= Symbol_ValueChanged;
                    }
                }

                // dispose custom event container
                _dynamicEvents.Dispose();


                // disconnect client
                if (_client.IsConnected)
                {
                    _client.Disconnect();
                }

                _client.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void Dispose_ClearsList()
        {
            var list = new EventHandlerList();

            // Create two different delegate instances
            Action a1 = () => Assert.True(false);
            Action a2 = () => Assert.False(true);

            Assert.NotSame(a1, a2);

            // Neither entry in the list has a delegate
            Assert.Null(list["key1"]);
            Assert.Null(list["key2"]);

            for (int i = 0; i < 2; i++)
            {
                // Add the delegates
                list.AddHandler("key1", a1);
                list.AddHandler("key2", a2);
                Assert.Same(a1, list["key1"]);
                Assert.Same(a2, list["key2"]);

                // Dispose to clear the list
                list.Dispose();
                Assert.Null(list["key1"]);
                Assert.Null(list["key2"]);

                // List is still usable, though, so loop around to do it again
            }
        }
Ejemplo n.º 4
0
        private void Dispose(bool disposing)
        {
            lock (_syncRoot)
            {
                if (_isDisposed)
                {
                    return;
                }

                _isDisposed = true;

                if (disposing)
                {
                    _fileSystemWatcher.Created            -= FileSystemWatcherOnChange;
                    _fileSystemWatcher.Changed            -= FileSystemWatcherOnChange;
                    _fileSystemWatcher.Renamed            -= FileSystemWatcherOnChange;
                    _fileSystemWatcher.Deleted            -= FileSystemWatcherOnChange;
                    _fileSystemWatcher.EnableRaisingEvents = false;
                    _fileSystemWatcher.Dispose();
                    _onChangeHandlers.Dispose();
                    _changeTimer.Dispose();
                }

                _fileSystemWatcher = null;
                _onChangeHandlers  = null;
                _changeTimer       = null;
            }
        }
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_events != null)
     {
         _events.Dispose();
         _events = null;
     }
 }
 public static void DeregisterWatchFile()
 {
     listEventDelegates?.Dispose();
     listEventDelegates = null;
     watcher?.Dispose();
     watcher     = null;
     certProfile = null;
 }
Ejemplo n.º 7
0
 protected virtual void Disposing(bool isDisposing)
 {
     if (isDisposing)
     {
         eventHandlers.Dispose();
         StopWatching();
     }
 }
Ejemplo n.º 8
0
		/// <summary>
		/// Releases the unmanaged resources used by the <see cref="ConfigurationNode"/> and optionally releases the managed resources.
		/// </summary>
		/// <param name="disposing">
		/// <see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.
		/// </param>
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				EventHandler handler = (EventHandler)handlerList[disposedEvent];
				if (handler != null) handler(this, EventArgs.Empty);
				if (handlerList != null) handlerList.Dispose();
				handlerList = null;
			}
		}
Ejemplo n.º 9
0
 /// <summary>
 /// <para>Releases the unmanaged resources used by the <see cref="ConfigurationBuilder"/> and optionally releases the managed resources.</para>
 /// </summary>
 /// <param name="disposing">
 /// <para><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</para>
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (null != events)
         {
             events.Dispose();
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Dispose attached events from Form.
        /// </summary>
        /// <param name="form">The form where the events are attached.</param>
        private static void DisposeEvents(this Form form)
        {
            PropertyInfo miEvents = form.GetType().GetProperty("Events", BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (miEvents != null)
            {
                EventHandlerList eventHandlerList = (EventHandlerList)miEvents.GetGetMethod(true).Invoke(form, new object[] { });
                eventHandlerList.Dispose();
            }
        }
Ejemplo n.º 11
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                fEventHandlers.Dispose();
                DataAdapter.InsertCommand.DisposeObject();
                DataAdapter.UpdateCommand.DisposeObject();
                DataAdapter.DeleteCommand.DisposeObject();
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 12
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisconnectFromEvents();
         if (events is not null)
         {
             events.Dispose();
             events = null;
         }
     }
 }
Ejemplo n.º 13
0
        public EventHandlerList DetachEvents(Component obj)
        {
            object       objNew     = obj.GetType().GetConstructor(new Type[] { }).Invoke(new object[] { });
            PropertyInfo propEvents = obj.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance);

            EventHandlerList eventHandlerList_obj    = (EventHandlerList)propEvents.GetValue(obj, null);
            EventHandlerList eventHandlerList_objNew = (EventHandlerList)propEvents.GetValue(objNew, null);

            eventHandlerList_objNew.AddHandlers(eventHandlerList_obj);
            eventHandlerList_obj.Dispose();

            return(eventHandlerList_objNew);
        }
        /// <summary>
        /// <para>Releases the unmanaged resources used by the <see cref="Common.Configuration.Storage.ConfigurationChangeFileWatcher"/> and optionally releases the managed resources.</para>
        /// </summary>
        /// <param name="isDisposing">
        /// <para><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</para>
        /// </param>
        protected virtual void Dispose(bool isDisposing)
        {
            if (isDisposing)
            {
                eventHandlers.Dispose();
                StopWatching();

                if (pollTimer != null)
                {
                    pollTimer.Dispose();
                }
            }
        }
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="ConfigurationUIHierarchyService"/> and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing">
 /// <see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         handlerList.Dispose();
         foreach (IConfigurationUIHierarchy hierarchy in hierarchies.Values)
         {
             IDisposable disposable = hierarchy as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
     }
 }
        /// <summary>
        /// Dispose the object.
        /// </summary>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_eventList != null)
                {
                    _eventList.Dispose();
                    _eventList = null;
                }

                if (_shellGateway != null)
                {
                    _shellGateway = null;
                }
            }
        }
Ejemplo n.º 17
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (SettingLoadedEventHanderList != null)
                {
                    SettingLoadedEventHanderList.Dispose();
                    SettingLoadedEventHanderList = null;
                }
            }
            _disposed = true;
        }
Ejemplo n.º 18
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                DockPanel = null;
                if (m_autoHideTab != null)
                {
                    m_autoHideTab.Dispose();
                }
                if (m_tab != null)
                {
                    m_tab.Dispose();
                }

                Form.Disposed    -= Form_Disposed;
                Form.TextChanged -= Form_TextChanged;
                m_events.Dispose();
            }
        }
Ejemplo n.º 19
0
        public virtual void End()
        {
            if (State != ContextState.Active)
            {
                return;
            }

            State = ContextState.Ending;
            Raise(ContextEvents.ContextEnding, this as TContext);

            try
            {
                Unwind();
                InternalEnd();
            }
            finally
            {
                State = ContextState.Ended;
                Raise(ContextEvents.ContextEnded, this as TContext);
                _events.Dispose();
                _events = null;
            }
        }
Ejemplo n.º 20
0
        public void Dispose_ClearsList()
        {
            var list = new EventHandlerList();

            // Create two different delegate instances.
            Action action1 = () => Assert.True(false);
            Action action2 = () => Assert.False(true);

            // The list is still usable after disposal.
            for (int i = 0; i < 2; i++)
            {
                // Add the delegates
                list.AddHandler("key1", action1);
                list.AddHandler("key2", action2);
                Assert.Same(action1, list["key1"]);
                Assert.Same(action2, list["key2"]);

                // Dispose to clear the list.
                list.Dispose();
                Assert.Null(list["key1"]);
                Assert.Null(list["key2"]);
            }
        }
Ejemplo n.º 21
0
        public void All()
        {
            EventHandlerList list = new EventHandlerList();
            string           i1   = "i1";
            string           i2   = "i2";
            EventHandler     one  = new EventHandler(Deleg1);
            EventHandler     two  = new EventHandler(Deleg2);
            EventHandler     d;

            Assert.IsNull(list [i1], "All #01");
            Assert.IsNull(list [i2], "All #02");

            list.AddHandler(i1, one);
            d = list [i1] as EventHandler;
            Assert.IsNotNull(d, "All #03");

            d(this, EventArgs.Empty);
            Assert.AreEqual(1, calls, "All #04");

            list.AddHandler(i2, two);
            d = list [i1] as EventHandler;
            Assert.IsNotNull(d, "All #05");

            d(this, EventArgs.Empty);
            Assert.AreEqual(2, calls, "All #06");

            d = list [i2] as EventHandler;
            Assert.IsNotNull(d, "All #07");

            d(this, EventArgs.Empty);
            Assert.AreEqual(4, calls, "All #08");

            list.AddHandler(i2, two);
            d = list [i2] as EventHandler;
            Assert.IsNotNull(d, "All #08");

            d(this, EventArgs.Empty);
            Assert.AreEqual(16, calls, "All #09");

            list.RemoveHandler(i1, one);
            d = list [i1] as EventHandler;
            Assert.IsNull(d, "All #10");

            list.RemoveHandler(i2, two);
            d = list [i2] as EventHandler;
            Assert.IsNotNull(d, "All #11");

            list.RemoveHandler(i2, two);
            d = list [i2] as EventHandler;
            Assert.IsNull(d, "All #12");

            list.AddHandler(i1, one);
            d = list [i1] as EventHandler;
            Assert.IsNotNull(d, "All #13");

            list.AddHandler(i2, two);
            d = list [i2] as EventHandler;
            Assert.IsNotNull(d, "All #14");

            list.AddHandler(i1, null);
            Assert.IsNotNull(list [i1], "All #15");

            list.AddHandler(i2, null);
            Assert.IsNotNull(list [i2], "All #16");

            list.Dispose();
        }
Ejemplo n.º 22
0
 public void Dispose()
 {
     events.Dispose();
 }
Ejemplo n.º 23
0
 protected override void Release()
 {
     _eventHandlers.Dispose();
 }
Ejemplo n.º 24
0
        public void All()
        {
            EventHandlerList list = new EventHandlerList();
            string           i1   = "i1";
            string           i2   = "i2";
            EventHandler     one  = new EventHandler(Deleg1);
            EventHandler     two  = new EventHandler(Deleg2);
            EventHandler     d;

            Assertion.AssertEquals("All #01", null, list [i1]);
            Assertion.AssertEquals("All #02", null, list [i2]);

            list.AddHandler(i1, one);
            d = list [i1] as EventHandler;
            Assertion.Assert("All #03", d != null);

            d(this, EventArgs.Empty);
            Assertion.AssertEquals("All #04", 1, calls);

            list.AddHandler(i2, two);
            d = list [i1] as EventHandler;
            Assertion.Assert("All #05", d != null);

            d(this, EventArgs.Empty);
            Assertion.AssertEquals("All #06", 2, calls);

            d = list [i2] as EventHandler;
            Assertion.Assert("All #07", d != null);

            d(this, EventArgs.Empty);
            Assertion.AssertEquals("All #08", 4, calls);

            list.AddHandler(i2, two);
            d = list [i2] as EventHandler;
            Assertion.Assert("All #08", d != null);

            d(this, EventArgs.Empty);
            Assertion.AssertEquals("All #09", 16, calls);

            list.RemoveHandler(i1, one);
            d = list [i1] as EventHandler;
            Assertion.Assert("All #10", d == null);

            list.RemoveHandler(i2, two);
            d = list [i2] as EventHandler;
            Assertion.Assert("All #11", d != null);

            list.RemoveHandler(i2, two);
            d = list [i2] as EventHandler;
            Assertion.Assert("All #12", d == null);

            list.AddHandler(i1, one);
            d = list [i1] as EventHandler;
            Assertion.Assert("All #13", d != null);

            list.AddHandler(i2, two);
            d = list [i2] as EventHandler;
            Assertion.Assert("All #14", d != null);

            list.AddHandler(i1, null);
            Assertion.Assert("All #15", list [i1] != null);

            list.AddHandler(i2, null);
            Assertion.Assert("All #16", list [i2] != null);

            list.Dispose();
        }
Ejemplo n.º 25
0
        public void Dispose_ClearsList()
        {
            var list = new EventHandlerList();

            // Create two different delegate instances
            Action a1 = () => Assert.True(false);
            Action a2 = () => Assert.False(true);
            Assert.NotSame(a1, a2);

            // Neither entry in the list has a delegate
            Assert.Null(list["key1"]);
            Assert.Null(list["key2"]);

            for (int i = 0; i < 2; i++)
            {
                // Add the delegates
                list.AddHandler("key1", a1);
                list.AddHandler("key2", a2);
                Assert.Same(a1, list["key1"]);
                Assert.Same(a2, list["key2"]);

                // Dispose to clear the list
                list.Dispose();
                Assert.Null(list["key1"]);
                Assert.Null(list["key2"]);

                // List is still usable, though, so loop around to do it again
            }
        }