开发者

StructureMap configure

I am sorry to ask silly question, but I don't know how to define my question in the search engine.

I am using StructureMap like this:

ObjectFactory.Configure(x =>
    {
        x.For(typeof(IUtils)).Use(typeof(EFUtils));
    });

Now I need to add something like this to the configuration:

开发者_开发技巧x.For<IList<IMovementsManager>>().Return(
    new List<IMovementsManager>() { 
        new TaskManager(),
        new WarehouseManager()
    });

What is the syntax to do so?

EDIT:

In order to make it more clear, whenever the user asks for IList<IMovementsManager> the StructureMap should return the following instance:

new List<IMovementsManager>() { 
            new TaskManager(),
            new WarehouseManager()
        }


I think what you want (I don't have VS handy to quickly test) is to scan them like:

ObjectFactory.Configure(c => c.Scan(x =>
             {
                 x.TheCallingAssembly();
                 x.AddAllTypesOf<IMovementsManager>();
             }));

Here's the StructureMap documentation for registering all concrete instance of a type:

http://structuremap.net/structuremap/ScanningAssemblies.htm#section5

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜