Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# structuremap注册表中缺少SetAllProperties方法_C#_Structuremap - Fatal编程技术网

C# structuremap注册表中缺少SetAllProperties方法

C# structuremap注册表中缺少SetAllProperties方法,c#,structuremap,C#,Structuremap,我有一个相当老的项目,需要做一些工作,我在nuget中运行了更新包,现在在我的TypeRegistry中获得了以下内容 当前作用域中不存在名称“SetAllProperties” TypeRegistry如下所示 public class TypeRegistry : Registry { public TypeRegistry() { For<ILogger>().Singleton().Use<Log4NetLogger>

我有一个相当老的项目,需要做一些工作,我在nuget中运行了更新包,现在在我的TypeRegistry中获得了以下内容

当前作用域中不存在名称“SetAllProperties”

TypeRegistry如下所示

public class TypeRegistry : Registry
    {
    public TypeRegistry()
        {
        For<ILogger>().Singleton().Use<Log4NetLogger>();
        this.SetAllProperties(p => p.OfType<ILogger>());
        }
    }
公共类类型注册表:注册表
{
公共类型注册表()
{
For().Singleton().Use();
this.SetAllProperties(p=>p.OfType());
}
}

谁能解释一下为什么会出现这种情况,并给我指出任何可以帮助我解决这个问题的方法。

我也遇到了这个问题。我认为这种方法在新版本中可能已经被弃用了。我能够使用Registry类的
Policies
属性完成setter注入

public class TypeRegistry : Registry
{
    public TypeRegistry()
    {
        For<ILogger>().Singleton().Use<Log4NetLogger>();
        Policies.FillAllPropertiesOfType<ILogger>().Use<Log4NetLogger>();
    }
}
公共类类型注册表:注册表
{
公共类型注册表()
{
For().Singleton().Use();
Policies.FillAllPropertiesOfType().Use();
}
}
编辑:

刚刚在策略上找到了SetAllProperties方法。我相信任何一方都会注入财产

var container = new Container(x =>
{
    x.Policies.SetAllProperties(
        policy => policy.WithAnyTypeFromNamespace("StructureMap.Testing.Widget3"));
});
请参见此处的官方文档

关注“当前范围”。如果作用域包含另一个名为“Registry”的接口或类,则会出现此编译错误。请尝试键入全名StructureMap.Configuration.DSL.Registry。