I am trying to implement the pattern as described here http://stevesmithblog.com/blog/building-a-cachedrepository-via-strategy-pattern/ but using unity (the example uses StructureMap)
I am trying to replicate this code in Unity syntax
x.For&开发者_开发技巧lt;IOrganization>().Use<OrganizationCacheRepository>().Ctor<IOrganization>).Is<OrganizationRepository>();
Any ideas?
You'll want to do something like:
_container.RegisterType<IOrganization,OrganizationCacheRepository>(new Injection Constructor(new []{new ResolvedParameter<OrganizationRepository>()});
Where RegisterType registers the initial interface/type mapping and IjectionConstructor maps the paramters to be injected into the object when it is created.
We use a ResolvedParameter to tell Unity to resolve an instance from a type/interface from the container and use it as an injection parameter.
精彩评论