首页 新闻 会员 周边 捐助

源代码添加注释(依赖注入)

0
悬赏园豆:20 [已关闭问题]

以下的代码麻烦熟悉的朋友帮助添加一下注释,最好是能详细一些,我对依赖注入这一块有些了解而已,实在是有点看不太明白.非常谢谢!

代码
private static readonly TransparentProxyInterceptor injector = new TransparentProxyInterceptor();

public static IUnityContainer Container
{
get; private set; }

static ServiceLoader()
{
UnityConfigurationSection unitySection
= ConfigurationManager.GetSection("unity") as UnityConfigurationSection;
if (unitySection == null)
{
throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "Missing Unity configuration section."));
}

Container
= new UnityContainer();
UnityContainerElement containerElement;
containerElement
= unitySection.Containers.Default;
containerElement.Configure(Container);
Container.AddNewExtension
<Interception>();
}

public static T LoadService<T>()
{
Container.Configure
<Interception>().SetDefaultInterceptorFor(typeof(T), injector);
return Container.Resolve<T>();
}

public static T LoadService<T>(string serviceName)
{
Container.Configure
<Interception>().SetDefaultInterceptorFor(typeof(T), injector);
return Container.Resolve<T>(serviceName);
}

 

denli的主页 denli | 初学一级 | 园豆:19
提问于:2010-07-13 08:36
< >
分享
其他回答(1)
0

这段代码用的是MS的Unity框架吧

用注释不太好描述清楚

建议你看看这篇文章,是讲Unity的,写的很好,相信你看完之后就明白了

http://www.cnblogs.com/Terrylee/archive/2008/02/21/unity-application-block-part1.html

LanceZhang | 园豆:857 (小虾三级) | 2010-07-13 17:53
0

看不懂~!飘过

肆季风 | 园豆:250 (菜鸟二级) | 2010-07-13 18:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册