Note that there are some explanatory texts on larger screens.

plurals
  1. PODependency Injection - Choose DLL and class implementation at runtime through configuration file
    text
    copied!<p>I've an API DLL (<strong><em>API.dll</em></strong>, for example) which, in addition to many other thinks, makes available an abstract class (<strong><em>AbstractClass</em></strong>).</p> <p>Now making use of that <em>AbstractClass</em> I've implemented it on two different dlls:</p> <ul> <li><em><strong>First.API.Implementation.dll</em></strong> with <strong><em>ConcreteImplementation1</em></strong></li> <li><em><strong>Second.API.Implementation.dll</em></strong> with <strong><em>ConcreteImplementation2</em></strong></li> </ul> <p><em>Both ConcreteImplementation1 and ConcreteImplementation2 are implementation of the same abstract class.</em></p> <p>What I want is an application where I can choose which of those two dlls to use and, through that, choose which implementation to use without the user having to change anything within the code and, if possible, without stopping the application.</p> <p>Some configuration file where I can bring the application to use whatever implementation I want. Something like:</p> <pre><code>&lt;appconfiguration&gt; &lt;implementation_to_use&gt; &lt;dll&gt;First.API.Implementation.dll&lt;/dll&gt; &lt;class&gt;ConcreteImplementation1&lt;/class&gt; &lt;/implementation_to_use&gt; &lt;/appconfiguration&gt; </code></pre> <p>I know near to nothing about dependency injection, apart from its concept, but I guess thats the perfect fit for this task.</p> <p>I've researched several DI/IoC libraries but I'm not familiar with all the concepts and names. I can use whatever library I want. For what I can say these are the most used: <a href="http://structuremap.net/structuremap/" rel="nofollow">StructureMap</a>, <a href="http://ninject.org/" rel="nofollow">Ninject</a> and <a href="http://www.springframework.net/" rel="nofollow">Sprint.NET</a></p> <p>Moreover, apart from all the dlls and implementation I need to indicate a file to be used by that application. Can I indicate its path in that same file?</p> <p>I just need some tips and directions to implement such a thing. Some examples using one of those libraries, would be awesome.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload