This scenario explores how you can retrieve concrete instances of registered object from a Unity container using the Resolve method.
In this scenario, you retrieve the default (un-named) instance of a registered object, a reference to a singleton, or a reference to an existing object managed by the container, using only the the object registration type.
To retrieve object instances from the container, use the Resolve method. When you use this method without specifying a value for the optional name property, the method returns the object registered with the default mapping.
To retrieve an object from the container using the default mapping
IMyService result = myContainer.Resolve<IMyService>();
Dim result As IMyService = myContainer.Resolve(Of IMyService)()
MyServiceBase result = myContainer.Resolve<MyServiceBase>();
Dim result As MyServiceBase = myContainer.Resolve(Of MyServiceBase)()
CustomerService result = (CustomerService)myContainer.Resolve<MyServiceBase>();
Dim result As CustomerService = myContainer.Resolve(Of MyServiceBase)()
For more information about the techniques discussed in this scenario, see the following topics: