我正在將一個項目從Visual Studio 2005轉換爲Visual Studio 2008,並且出現在上述構造中。()=>構造
using Castle.Core.Resource;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using CommonServiceLocator.WindsorAdapter;
using Microsoft.Practices.ServiceLocation;
namespace MyClass.Business
{
public class Global : System.Web.HttpApplication
{
public override void Init()
{
IServiceLocator injector =
new WindsorServiceLocator(
new WindsorContainer(
new XmlInterpreter(
new ConfigResource("oauth.net.components"))));
//ServiceLocator.SetLocatorProvider(() => injector);
// ServiceLocator.SetLocatorProvider(injector);
}
}
}
ServiceLocator.SetLocatorProvider(()=> injector);
我可以理解這是什麼。
匿名代理看起來更像'new delegate(){return injector; }'。當然,在這種情況下,lamdba表達式具有創建匿名委託的效果。 – 2010-07-16 14:28:18
你是對的,我很匆忙。我編輯了我的答案,以更好地闡明這一點。 – 2010-07-16 14:41:00