Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: How to create a separate XAP file using Prism/MEFBootstrapper for a complex Child Window?

$
0
0

Hi Warren,

I'm glad you could make the approaches work, regarding your concerns:

  1. Take into account that when using dependency injection containers like MEF you can also use the constructor injection approach. This way you can specify imports through constructor parameters by adding the[System.ComponentModel.Composition.ImportingConstructorAttribute] attribute to your constructor. As far as I know, in cases where your class is defined with multiple constructorsMEF will use the one where you put this attribute.
    For more information about this you could check the Declaring Imports section of the MEF Programming Guide.
  2. Based on my understanding, you won't be able to export a Static class to a container like MEF as this is designed to create and initialize instances of classes for you and keep a collection of these instances, which may not be possible forStatic classes. On the other, by default MEF threats theirImports / Exports as Singletons instances, in which case, I believe the use of static classes could be replaced by the use of theseSingleton instances.
  3. Regarding the use of interfaces to export your classes, as seen before this might not always be necessary. But it will be required when you need loosely coupling between your components, as this will allow you to have an importer to be completely decoupled from the specific implementation of the exported type.
  4. As far as I know, another dependency injection container that supports the constructor injection approach isUnity, which in cases where a target class contains multiple constructors,  this container will use the one that has theInjectionConstructor attribute applied to. Also, if there is more than one constructor, and none carries theInjectionConstructor attribute, Unity will use the constructor with the most parameters. For more information on this subject, you could check theAnnotating Objects for Constructor Injection section of theUnity documentation.

I hope you find this handy,

Agustin Adami
http://blogs.southworks.net/aadami


Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>