开发者

Structure Map 2.6.1

In my current project I'm currently trying to replace the Windsor IoC in favour of structure map (2.6.1). But having a bit of problem registerin开发者_开发知识库g some generic types. How would I register IFilterConverter<T> to use FilterConverter<SomeSpecificType>. I've tried ConnectImplementationsToTypesClosing(IFilterConverter) but from what I've read (Jimmy Bogard's article) I would need a concrete type defined like so:- SomeConcreteType : IFilterConverter<SomeSpecificType> for that to work and I don't have that.

So to reiterate if I have a type that takes a constructor argument IFilterConverter<SomeSpecificType>, I want structure map to provide me with FilterConverter<SomeSpecificType>.

With Windsor I was using the XML config option (which I want to get away from) But all I did was just set up the configuration like so:

<component id="IFilterConverter" service="SomeNamespace.IFilterConverter`1, SomeNamespace" type="SomeNamespace.FilterConverter`1, SomeNamespace" lifestyle="PerWebRequest">

How do I do the equivalent in SM (using code, not XML config files)

Thanks


I think this should do it.

_container = new Container();
_container.Configure(x =>
                         {
                             x.For(typeof (IFilterConverter<>)).Use(typeof (FilterConverter<>));
                         });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜