Posts Tagged ‘StructureMap’

In my last post I had completed the demo of building a layered ASP.NET MVC application(the bookmark list application).This week I thought of adding the StructureMap container to that demo.I am quite new to StructureMap but I loved it’s usage of Fluent Interfaces and DSL a lot.I have primarily applied what I understood from it’s online documentation.I wanted to keep the option of plugging in another container later in this application.So I defined my own container interface as shown below:

    public interface  IContainer {
void AddInstanceConfig<I, T>(string key) where T:I; //Configures an instance with instance key,type and concrete type
void StartContainer(); //Starts the Container
object GetInstance<I>(string instanceName); //Returns an object instance based on the instance key/name
void DestroyContainer(); //destroys the container and releases the references