what "Resolve" really mean?

Jul 7, 2011 at 10:26 PM

I don't understand follow sentence, please help:

 

var dt = Unity.Container.Resolve<System.Data.DataTable>("Boo");

 

It seems that everything has been registered ,what this "Resolve" exact mean?

 

Thank you,

Jie

Jul 8, 2011 at 4:31 AM

Hi,

Resolve means you are asking the Unity to provide you an instance of the registered type. In your case, you are asking the unity to provide you an instance of type DataTable. Note that you should have already registered the type to the unity container before attempting to resolve it.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 8, 2011 at 2:07 PM

thank you so much!!

Jul 8, 2011 at 2:34 PM

By the way, what that "boo" mean?

Jul 11, 2011 at 3:29 AM
Edited Jul 11, 2011 at 3:31 AM

It means you have registered a type named "Boo" and you are resolving that type using its name. For example you have a type "IGeneralType" and you registered it in different ways:

UnityContainer.RegisterType<IGeneralType,MyDefaultType>()
UnityContainer.RegisterType<IGeneralType,MyFirstType>("Boo");
UnityContainer.RegisterType<IGeneralType,MySecondType>("Foo");

If you want to resolve MyFirstType, you will do:

UnityContainer.Resolve<IGeneralType>("Boo");

If you didn't specify a name, it will return the default registration, which is the MyDefaultType.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com