This project has moved. For the latest updates, please go here.

Adding new Parts dynamically

Feb 7, 2009 at 10:59 PM

By using of DirectoryCatalog, one can be notified when new parts appear in the watching directory.
To do this I used the event handler “Changed” of the DirectoryCatalog. This is fine. but a bit to complicate.

I would like to know what is proposed (easiest) way to compose new part by using of information contained in ComposablePartCatalogChangedEventArgs.

By the way wouldn’t be useful to provide shadowing of loaded assemblies? In this case one could be able to unload the assembly, which is possibly replaced by the new one?




Feb 9, 2009 at 6:00 PM
Changes in catalogs trigger recomposition in the container.  If you set the AllowRecomposition property of an import attribute to true, then the import can change on recomposition.  You can add custom logic in a property setter to detect when it changes, or you can import into an ObservableCollection property (without implementing a setter, to be safe) and listen for changes to the collection.  Is this what you are looking for?

Assembly shadowing can be enabled in your app.config, or by setting the ShadowCopyFiles property of the AppDomainSetup when you create a new AppDomain.