其他分享
首页 > 其他分享> > Enterprise Library 5 系列之1——Application Block的使用

Enterprise Library 5 系列之1——Application Block的使用

作者:互联网

Application Block的对象、原型(Facades)与工厂

Application Block

Non-static Instance or Factory

Caching

ICacheManager

Cryptography

CryptographyManager

Data Access

Database

Exception Handling

ExceptionManager

Logging

LogWriter

TraceManager

Security

ISecurityCacheProvider

IAuthorizationProvider

Validation

ValidatorFactory

ConfigurationValidatorFactory

AttributeValidatorFactory

ValidationAttributeValidatorFactory

 

服务定位器(Service Locator)

var writer = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

var customerDb = EnterpriseLibraryContainer.Current.GetInstance<Database>("Customers");

 

访问容器

var theContainer = new UnityContainer() .AddNewExtension<EnterpriseLibraryCoreExtension>();

var writer = theContainer.Resolve<LogWriter>();

var customerDb = theContainer.Resolve<Database>("Customers");

 

需引用的程序集:

以上两种方法的优缺点,见https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff953191(v=pandp.50)

 

标签:Resolve,Library,Application,Unity,theContainer,Enterprise,var,Block
来源: https://www.cnblogs.com/5x19/p/16584772.html