You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to do something like this. I'm a little confused because I swear LightInject supported this, but not working for me. Very simply, when calling InjectProperties(obj) on some object, I want it to scan the full nested structure and inject everything. So inject properties of property objects. Inject properties of objects in collections. And so on. Thanks!
public class InjectableObject
{
[Inject]
public IFoo _foo { get; set; }
private readonly Guid _id;
public Guid Id => _id;
public InjectableObject()
{
_id = Guid.NewGuid();
}
}
public class InjectableObjectWithCollection
{
[Inject]
public IFoo _foo { get; set; }
public List<InjectableObject> MyCollection { get; set; }
public InjectableObject Test { get; set; }
public InjectableObjectWithCollection()
{
MyCollection = new List<InjectableObject>();
MyCollection.Add(new InjectableObject());
MyCollection.Add(new InjectableObject());
Test = new InjectableObject();
}
}
var objectWithCollection = new InjectableObjectWithCollection();
container.InjectProperties(objectWithCollection);
The text was updated successfully, but these errors were encountered:
I am trying to do something like this. I'm a little confused because I swear LightInject supported this, but not working for me. Very simply, when calling InjectProperties(obj) on some object, I want it to scan the full nested structure and inject everything. So inject properties of property objects. Inject properties of objects in collections. And so on. Thanks!
The text was updated successfully, but these errors were encountered: