I have a simple class:
public class MyWidget
{
private string _something;
public MyWidget(string name)
{
}
public string Something
{
get { return _something; }
set { _something = value; }
}
}
which I register with Autofac:
var builder = new ContainerBuilder();
builder.RegisterType<MyWidget>();
var container = builder.Build();
If I enable factory and create an instance of MyWidget:
var myWidgetFactory = Container.Resolve<Func<string, MyWidget>>();
var myWidget = myWidgetFactory("test");
The Something property is set to test, although it has nothing to do with the constructor parameter. Why does Autofac think it should set the first property it comes to? How can I prevent this? I am using Autofac v4.0.0.
source
share