0

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.

Neil Stevens
  • 3,534
  • 6
  • 42
  • 71
  • Focus on "current scope". If the scope contains another interface or class named "Registry" then you will get this compile error. Try typing the full name instead, StructureMap.Configuration.DSL.Registry. – Hans Passant Jun 25 '15 at 12:44

2 Answers2

0

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.

CSharper
  • 5,420
  • 6
  • 28
  • 54
0
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/

Sameer Alibhai
  • 3,092
  • 4
  • 36
  • 36