Reputation: 2004
I've been updated to structuremap 3, and now I can't use FillAllPropertiesOfType for setter injection.
Is it deprecated, what should I use instead?
Upvotes: 5
Views: 2203
Reputation: 4230
I just ran into the same problem. Looks like the new way to do this is via Registry.PoliciesExpression
.
public interface IInjectable
{
string Test();
}
public class Injectable : IInjectable
{
public string Test()
{
return this.GetType().ToString();
}
}
public class InjectTarget
{
public IInjectable Injectable
{
get;
set;
}
}
static class Program
{
static void Main()
{
ObjectFactory.Configure(x =>
{
//Setter injection
x.Policies.FillAllPropertiesOfType<IInjectable>().Use<Injectable>();
//Standard registration
x.For<IInjectable>().Use<Injectable>();
x.For<InjectTarget>().Singleton().Use<InjectTarget>();
});
var test = ObjectFactory.GetInstance<InjectTarget>();
Console.WriteLine(test.Injectable.Test()); //WindowsFormsApplication3.Injectable
}
}
Upvotes: 5