I'm trying the following in Unity:
I have a type with the following constructor
public Type1(Type2 firstDependency, Type3 secondDependency)
When resolving Type1
using Unity, I want to specify the specific instance for Type2
to inject. This specific instance of Type2
is not registered in the container. Type3
is registered in the container and should be resolved as usual.
To be more specific, consider Type1
is a DocumentViewer
class. Type2
is a specific Document
. Type3
is a SpellingChecker
.
I want to be able to resolve DocumentViewer
for a Document
that is only known at runtime. Multiple DocumentViewer
instances for differenct Documents
can be created.
How can I do this?