Example #1
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// <returns>
        ///     <c>true</c> if operation is allowed
        /// </returns>
        protected virtual bool Dispose(bool disposing)
        {
            if (IsDisposed || !disposing)
            {
                return(false);
            }
            IsDisposed = true;

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

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

            _id = null;

#if !UNITY3D
            Debug.WriteLine(string.Format("Dispose {0}", GetType()));
#else
            Debug.Log(string.Format("Dispose {0}", GetType()));
#endif

            return(true);
        }
Example #2
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// <returns></returns>
        protected override bool Dispose(bool disposing)
        {
            if (!disposing)
            {
                return(false);
            }

            _isActive = false;

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

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

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

            if (_canExecuteChangedHandlers != null)
            {
                _canExecuteChangedHandlers.Dispose();
                _canExecuteChangedHandlers = null;
            }
            return(base.Dispose(true));
        }