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); }
/// <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; }
public void Dispose() { _exportProvider.Dispose(); }