There are mutiple ways to access application blocks :
Using the Enterprise Library Service Locator
var writer = EnterpriseLibraryContainer.Current.GetInstance();
writer.Write("I'm a log entry created by the Logging block!");
var customerDb
= EnterpriseLibraryContainer.Current.GetInstance("Customers");
The Sophisticated Approach — Accessing the Container Directly
var theContainer = new
UnityContainer().AddNewExtension();
var writer = theContainer.Resolve();
writer.Write("I'm a log entry created by the Logging block!");
var customerDb = theContainer.Resolve("Customers");
Check out this diagram :
http://msdn.microsoft.com/en-us/library/Ff953191.441da4ba-fa2e-4da3-bac1-89897580d80b(l=en-us,v=PandP.50).png
No comments:
Post a Comment