-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
public class B
{
public B(A a)
{
A = a;
}
public A A;
}
public class A
{
public int Value;
}
public static class Program
{
public static void Main()
{
var container = new DependencyInjectionContainer();
container.Configure(c =>
{
// c.ExcludeTypeFromAutoRegistration(typeof(A)); // Uncomment this line for correct answer
});
var origA = new A() { Value = 5 };
var subContainer = container.CreateChildScope();
subContainer.Configure(c =>
{
c.ExcludeTypeFromAutoRegistration(typeof(A)); // This line is useless
});
B obj = subContainer.Locate<B>(new {
a = origA
});
Console.Write($"obj A val = {obj.A.Value}"); // This will write "obj A val = 0", expected result: "obj A val = 5"
}
}
Here is the code illustrating example. If I exclude AutoRegistration in child container (I want to override parent behaviour) it won't work. I need to exclude it in parent container.
So Excluding in child containers dosn't do anything.
Metadata
Metadata
Assignees
Labels
No labels