예제 #1
0
        private void DoClose(bool saveStore = true)
        {
            if (!this.IsOpen)
            {
                throw new InvalidOperationException(Resources.PatternManager_CloseInvalidIfNotOpen);
            }

            using (tracer.StartActivity(Resources.PatternManager_TraceClosingStore, this.StoreFile))
            {
                if (saveStore)
                {
                    this.Save();
                }

                this.Store.TransactionCommited -= this.OnTransactionCommitedDoSave;
                this.Store.ElementInstantiated -= this.OnElementInstantiated;
                this.Store.ElementCreated      -= this.OnElementCreated;
                this.Store.ElementLoaded       -= this.OnElementLoaded;
                this.Store.ElementDeleted      -= this.OnElementDeleted;
                this.Store.ElementDeleting     -= this.OnElementDeleting;

                this.productStore.Store.Dispose();

                if (this.validationController != null)
                {
                    this.validationController.ClearMessages();
                    this.validationController.RemoveObserver(this.errorListObserver);
                    this.validationController = null;

                    if (this.errorListObserver != null)
                    {
                        this.errorListObserver.Dispose();
                        this.errorListObserver = null;
                    }
                }

                this.IsOpen = false;
                this.RaiseIsOpenChanged();
            }
        }
예제 #2
0
        /// <summary>
        /// When the doc data is closed, make sure we reset the valiation messages
        /// (if there's any) from the ErrorList window.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (this.validationController != null)
                {
                    this.validationController.ClearMessages();
                    // un-register our observer with the controller.
                    if (this.errorListObserver != null)
                    {
                        this.validationController.RemoveObserver(this.errorListObserver);

                        this.errorListObserver.Dispose();
                        this.errorListObserver = null;
                    }
                    this.validationController = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }