示例#1
0
        /// <summary>
        /// Indicates the object is being disposed.
        /// </summary>
        /// <param name="disposing">Indicates <see cref="ViewModel.Dispose(bool)"/> was invoked through an explicit call to <see cref="ViewModel.Dispose()"/> instead of a finalizer call.</param>
        protected override void Dispose(bool disposing)
        {
            if (elementScope != null)
            {
                elementScope.CollectionChanged -= ElementScopeCollectionChanged;
                elementScope.Dispose();
                elementScope = null;
            }

            if (reference != null)
            {
                reference.ElementFound   -= ReferenceElementFound;
                reference.ElementDeleted -= ReferenceElementDeleted;
                reference.NameChanged    -= ReferenceNameChanged;

                reference.Dispose();
                reference = null;
            }

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

            ((INotifyCollectionChanged)ValidationResults).CollectionChanged -= ValidationCollectionChanged;

            base.Dispose(disposing);
        }
示例#2
0
        private void EnsureScopeInitialized()
        {
            if (scopeInitialized)
            {
                return;
            }

            elementScope = new DeferredElementScope(referenceAttribute, base.DeclaringElement, lookup);
            elementScope.CollectionChanged += ElementScopeCollectionChanged;

            changeScopePropertyWatcher.Refresh(elementScope);
            scopeInitialized = true;
        }
        /// <summary>
        /// Indicates the object is being disposed.
        /// </summary>
        /// <param name="disposing">Indicates <see cref="ViewModel.Dispose(bool)"/> was invoked through an explicit call to <see cref="ViewModel.Dispose()"/> instead of a finalizer call.</param>
        protected override void Dispose(bool disposing)
        {
            if (elementScope != null)
            {
                elementScope.CollectionChanged -= ElementScopeCollectionChanged;
                elementScope.Dispose();
                elementScope = null;
            }

            if (reference != null)
            {
                reference.ElementFound -= ReferenceElementFound;
                reference.ElementDeleted -= ReferenceElementDeleted;
                reference.NameChanged -= ReferenceNameChanged;

                reference.Dispose();
                reference = null;
            }

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

            ((INotifyCollectionChanged)ValidationResults).CollectionChanged -= ValidationCollectionChanged;

            base.Dispose(disposing);
        }
        private void EnsureScopeInitialized()
        {
            if (scopeInitialized) return;

            elementScope = new DeferredElementScope(referenceAttribute, base.DeclaringElement, lookup);
            elementScope.CollectionChanged += ElementScopeCollectionChanged;

            changeScopePropertyWatcher.Refresh(elementScope);
            scopeInitialized = true;
        }