c# - Breaking the .NET MEF import chain -


For this example, you might assume that the upper part is importing the class. By the time you import everything (i.e. ClassX), MEF works very well. Often you do not need to import because classb is in the same name space / file as a result the import chain is now broken and my logs are never created. In my example, Classbie Logger is trying to import the service, which may be the desire of almost all classes.

If anyone has the purpose / best MEF solution for this issue?

1) Once the import chain breaks down, then the import is never used again. Instead you will have to start constructing / constructing all types of constructor (i.e. new classbie) This works in this example, but it is messy if the intermediate classes are not used in the series.

2) Use the IceSwalker in system namespace to import Classbase, as far as I know that the Serverside (for example, the Prism Framework) is the only essence of dependency injection scheme. For example if classbie If ISISLL can import, then IOOGG can be imported into it.

3) Back to the previous Call Composabilities (Classbie). To prevent upper level on the basis of Classbie, I could apply Class B to ICB (ICOMXME), which will be sub-city importer after that it will be composed of upper portion for all ITM import on the container. I do not believe this objective solution This is because it has not been described or used in the MEF framework documentation.

4) Actually I'm out of ideas, please help ...

  class squares {// will be imported within ClassX [Import] ClassX myClassX ; // will not be imported within the classroom! Var myClassB = new ClassB} class ClassB {// fails because Classbys have never been created [import] IOiggers Marlog; MyLog.Display ("Hello World"); } [Export] Orbit Class X {// Works - Imported on imported Classics [Import] iLogger Mylog; MyLog.Display ("Hello World"); }    

Do you follow dependency injection patterns? Do not break the import chain In your application, a single structure should be root, where the components are wired together. Components should not be worried about achieving their reliance.

It is valid, in practice, you have to deal with the current code (and other developers suspected of DI) so that you do not always have to depend on injection "all the way down" in those cases as a global variable Expose the container and can pull the necessary dependencies from there.

To highlight a container globally, it is essentially a service locator pattern.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -