Ejemplo n.º 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>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (!_isDisposed)
                {
                    ExportProvider?rootProvider = null;
                    IDisposable?   disposableAncestorExportProvider    = null;
                    IDisposable?   disposableLocalExportProvider       = null;
                    IDisposable?   disposableRootProvider              = null;
                    ComposablePartExportProvider?partExportProvider    = null;
                    CatalogExportProvider?       catalogExportProvider = null;
                    ImportEngine?importEngine = null;

                    lock (_lock)
                    {
                        if (!_isDisposed)
                        {
                            rootProvider  = _rootProvider;
                            _rootProvider = null !;

                            disposableRootProvider  = _disposableRootProvider;
                            _disposableRootProvider = null;

                            disposableLocalExportProvider  = _disposableLocalExportProvider;
                            _disposableLocalExportProvider = null;
                            _localExportProvider           = null !;

                            disposableAncestorExportProvider  = _disposableAncestorExportProvider;
                            _disposableAncestorExportProvider = null;
                            _ancestorExportProvider           = null;

                            partExportProvider  = _partExportProvider;
                            _partExportProvider = null !;

                            catalogExportProvider  = _catalogExportProvider;
                            _catalogExportProvider = null;

                            importEngine  = _importEngine;
                            _importEngine = null;

                            _isDisposed = true;
                        }
                    }

                    if (rootProvider != null)
                    {
                        rootProvider.ExportsChanged  -= OnExportsChangedInternal;
                        rootProvider.ExportsChanging -= OnExportsChangingInternal;
                    }

                    disposableRootProvider?.Dispose();
                    disposableAncestorExportProvider?.Dispose();
                    disposableLocalExportProvider?.Dispose();
                    catalogExportProvider?.Dispose();
                    partExportProvider?.Dispose();
                    importEngine?.Dispose();
                }
            }
        }
Ejemplo n.º 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>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (!this._isDisposed)
                {
                    ExportProvider               rootProvider = null;
                    AggregateExportProvider      aggregatingExportProvider = null;
                    ComposablePartExportProvider partExportProvider        = null;
                    CatalogExportProvider        catalogExportProvider     = null;
                    ImportEngine importEngine = null;

                    lock (this._lock)
                    {
                        if (!this._isDisposed)
                        {
                            rootProvider       = this._rootProvider;
                            this._rootProvider = null;

                            aggregatingExportProvider       = this._aggregatingExportProvider;
                            this._aggregatingExportProvider = null;

                            partExportProvider       = this._partExportProvider;
                            this._partExportProvider = null;

                            catalogExportProvider       = this._catalogExportProvider;
                            this._catalogExportProvider = null;

                            importEngine       = this._importEngine;
                            this._importEngine = null;

                            this._isDisposed = true;
                        }
                    }

                    if (rootProvider != null)
                    {
                        rootProvider.ExportsChanged  -= this.OnExportsChangedInternal;
                        rootProvider.ExportsChanging -= this.OnExportsChangingInternal;
                    }

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

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

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

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