コード例 #1
0
        public void CanBeCollectedAfterDispose()
        {
            AggregateExportProvider sourceExportProvider = new AggregateExportProvider();
            var catalog = new AggregateCatalog(CatalogFactory.CreateDefaultAttributed());
            var catalogExportProvider = new CatalogExportProvider(catalog);

            catalogExportProvider.SourceProvider = sourceExportProvider;

            WeakReference weakCatalogExportProvider = new WeakReference(catalogExportProvider);

            catalogExportProvider.Dispose();
            catalogExportProvider = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.False(weakCatalogExportProvider.IsAlive);

            GC.KeepAlive(sourceExportProvider);
            GC.KeepAlive(catalog);
        }
コード例 #2
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing,
        /// or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (catalogExportProvider != null)
            {
                catalogExportProvider.Dispose();
            }

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

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

            compositionContainer = null;
            aggregateCatalog     = null;
            providers            = null;
        }
コード例 #3
0
 public void Dispose()
 {
     _exportProvider.Dispose();
 }