Register<IA, A>();
class B { public IA A {get;set;}}
//container inject this property because IA was registered
In autofac you can do
builder.RegisterType<A>().InjectProperties();
for this.
Is there any extension for unity to do this? Or may be extension which I can use as sample for implement this feature by myself?
This is not a simple task. To resolve it you should change Unity’s default behaviour of the property selector policy. You can change it. This is what I can propose
This is modified DefaultUnityPropertySelectorPolicy wich you can find in source code of unity.
After that you need to redefine default behaviour by using
UnityContainerExtensionmechanism.So now let’s imagine that you have following classes
so now this test should pass
But you should understand that this one would not
Update
I’ve played a little bit more and found out how to make this test work
this is can be done in following way
and adding clean up extension
You can download source file from here http://92.248.232.12/UnitTest1.zip