In Unity, is it possible to resolve a type from its type alias?

I registered several types in Unity and gave them type aliases as follows:

<typeAliases>
   <typeAlias alias="MyType" type="foo.bar.MyType, foo.bar" />
</typeAliases>

Is it possible to resolve these types from the container using aliases (as opposed to the type), according to the lines:

var myType = container.ResolveByTypeAlias("MyType")

I see no way to do this, but thought I was missing something.

+5
source share
2 answers

No, aliases exist only in the XML configuration. that is, they exist only in the configuration type.

http://msdn.microsoft.com/en-us/library/ff660933 (v = pandp.20) .aspx more about this

Aliases exist only during setup. They are not available at runtime.

+4
source

For my reference in the future -

, , Resolve ( ) , T .

-1

All Articles