English 中文(简体)
结构 地图工厂方法
原标题:StructureMap instance factory method

I m试图登记制造开放式通用型号的工厂方法:。 然而,当IGetInstance时,看来它使用的是MongoCollection的建筑商,而不是工厂方法。

var mongo = new MongoConfiguration("mongodb://localhost", "test");
For(typeof (MongoCollection<>)).Use(c =>
{
    var requestedType = c.BuildStack.Current.RequestedType; // set breakpoint here
    var type = requestedType.GetGenericArguments()[0];
    return mongo.GetCollection(type);
});

然后,我

ObjectFactory.GetInstance<MongoCollection<User>>();

当我操作<条码>GetInstance时,它从未在工厂方法内打过断点,而是扔下了<条码>StructureMapException,说“没有为PluginFamily MongoDb. 司机确定违约情况”。 有一个构造人<代码>MongoCollection ,使用,但我不想用结构图来使用该建筑商,我希望它使用我的工厂方法。

它为什么不使用工厂方法? 难道这是ug吗?

最佳回答

I forked the repository to browse the code and realized its definitely a bug. I fixed the bug and sent a pull request, hopefully it will be merged and released soon.

问题回答

暂无回答




相关问题
Structuremap (or any IoC, really) architecture question

I m going to use structuremap for a project I m working on. The basic gist is that I have a repository pattern with an NHibernate implementation, but I want to use StructureMap to load the ...

Inject static property with StructureMap?

is it possible inject static property, like I do below, because it does not work for me? public static IMerchantModule MerchantModule { get; set; } public RequestBaseValidationRules() { ...

Injecting Subsonic SimpleRepository class to controller

I m tryingot get started with IoC, I have an MVC project in which is use subsonic, I m trying to inject subsonic simplerepository to my controllers but I m getting this error: StructureMap Exception ...

StrucutureMap RhinoMock Record/Playback, Example needed

I m looking for some examples on how to do the following Mock Tests using StructureMap or Unity with NUnit. I have the following code structure public interface IDAL { List<Model> Method1(...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

热门标签