Structuremap ObjectFactory.GetAllInstances将空值插入列表

时间:2014-03-20 15:41:04

标签: c# .net dependency-injection inversion-of-control structuremap

我有一个非常简单的列表,我用Structuremaps ObjectFactory.GetAllInstances()实例化。

private List<UserReleaseTime> _UserReleaseTimes = 
    ObjectFactory.GetAllInstances<UserReleaseTime>().ToList()

UserReleaseTime如下所示:

public class UserReleaseTime
{
    public string name { get; set; }
    public double totalReleaseTime { get; set; }
    public double withinReleaseHours { get; set; }
    public double outsideReleaseHours { get; set; }
}

创建集合后,似乎structmap添加了一个空值或空值的对象。反正有没有阻止这种情况发生?

更新 UserReleaseTime在Structuremap中注册,如下所示:

For<UserReleaseTime>().Use<UserReleaseTime>();

0 个答案:

没有答案