SetAllProperties method missing in structuremap Registry

412 views Asked by At

I have a fairly old project that needs some work doing on it, i have run update-package in nuget and now get the following in my TypeRegistry

The name 'SetAllProperties' does not exist in the current scope

The TypeRegistry is as follows

public class TypeRegistry : Registry
    {
    public TypeRegistry()
        {
        For<ILogger>().Singleton().Use<Log4NetLogger>();
        this.SetAllProperties(p => p.OfType<ILogger>());
        }
    }

Can anyone explain why this is the case and point me to anything that could help me to resolve this problem please.

2

There are 2 answers

0
Sameer Alibhai On
var container = new Container(x =>
{
    x.Policies.SetAllProperties(
        policy => policy.WithAnyTypeFromNamespace("StructureMap.Testing.Widget3"));
});

See the official documentation here http://structuremap.github.io/setter-injection/

0
CSharper On

I ran into this problem as well. I think this method might have been deprecated in newer versions. I was able to accomplish setter injection using the Policies property of the Registry Class.

public class TypeRegistry : Registry
{
    public TypeRegistry()
    {
        For<ILogger>().Singleton().Use<Log4NetLogger>();
        Policies.FillAllPropertiesOfType<ILogger>().Use<Log4NetLogger>();
    }
}

Edit:

Just found the SetAllProperties method on Policies as well. I believe either one will inject the property.