StrcutureMap Wiring - Sanity Check Please

Posted by Steve Ward on Stack Overflow See other posts from Stack Overflow or by Steve Ward
Published on 2010-01-29T06:14:22Z Indexed on 2010/05/19 9:10 UTC
Read the original article Hit count: 282

Hi - Im new to IOC and StructureMap and have an n-level application and am looking at how to setup the wirings (ForRequestedType ...) and just want to check with people with more experience that this is the best way of doing it!

I dont want my UI application object to reference my persistence layer directly so am not able to wire everything up in this UI project.

I now have it working by defining a Registry class in each project which wires up the types in the project as needed. The layer above registers its types and also calls the assembly below and looks for registries so that all types are registered throught the hierrachy.

E.g. I have UI, Service, Domain, and Persistence libraries. In my service layer the registry looks like

        Scan(x =>
        {
            x.Assembly("MyPersistenceProject");
            x.LookForRegistries();
        });

        ForRequestedType<IService>().TheDefault.Is.OfConcreteType<MyService>();

Is this a recommended way of doing this in a setup such as this? Are there better ways and what are the advantages / disadvantages of these approaches in this case?

© Stack Overflow or respective owner

Related posts about inversion-of-control

Related posts about ioc-container