Extend Automatic Factories to automatically use Parameter Overrides
The current system of Automatic factories in Unity defers resolution when a class's constructor has a dependency of Func<IMyService>. This could be extended to automatically use parameter overrides when it sees a dependency of Func<SomeType,IMyService> and the concrete class implementing IMyService needs a parameter of type SomeType. This would only kick in if an InjectionFactory of the required type wasn't registered.
-
Mykola Musiienko commented
While Sebastian's code gets the job done, I believe it doesn't completely match the suggestion -- for example, it requires declaring a factory delegate and registering it in the container.
So, if anyone is still interested in this suggestion, I implemented a Unity extension, which, I believe, matches the suggestion exactly and also is more in line with the Unity's parameterless automatic factories experience.
-
Sebastian Weber commented
That feature already exists though it is not shipped as part of Unity
http://outlawtrail.wordpress.com/2012/07/27/generate-strongly-typed-factory-delegates/