Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get you started using <a href="https://github.com/structuremap/structuremap/downloads" rel="nofollow">StructureMap</a>, create a console application, include in it:</p> <p>structuremap.config:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;StructureMap MementoStyle="Attribute"&gt; &lt;DefaultInstance PluginType="DemoIoC.AbstractBase,DemoIoC" PluggedType="DemoIoC.ConcreteImplementation1,DemoIoC" Scope="Singleton" /&gt; &lt;/StructureMap&gt; </code></pre> <p>The PluginType and PluggedType attributes are "FullyQualifiedClassName,AssemblyName" By default it will look for assemblies in the executable folder, I'm not sure how you would specify another location for the assemblies</p> <p>There are plenty of options for Scope, e.g. Singleton, Transient, etc</p> <p>Program.cs:</p> <pre><code>namespace DemoIoC { using System; using StructureMap; public static class Program { public static void Main(string[] args) { // here you initialize structuremap from the config file. // You could probably use a FileSystemWatcher to reinitialize // whenever the structuremap.config file changes ObjectFactory.Initialize(x =&gt; { x.UseDefaultStructureMapConfigFile = true; }); var concrete = ObjectFactory.GetInstance&lt;AbstractBase&gt;(); concrete.Method1(); Console.ReadKey(true); } } } </code></pre> <p>AbstractBase.cs:</p> <pre><code>namespace DemoIoC { public abstract class AbstractBase { public abstract void Method1(); } } </code></pre> <p>ConcreteImplementation1.cs:</p> <pre><code>namespace DemoIoC { using System; public class ConcreteImplementation1 : AbstractBase { public override void Method1() { Console.WriteLine("Called ConcreteImplementation1"); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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