- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想猜测“环境容器”与它是一个静态类这一事实有关,但这只是一个猜测。
或者这是指标准模式? (也就是说,我真的需要从头到尾读完那本 GoF 书)
namespace Microsoft.Practices.ServiceLocation
{
/// <summary>
/// This class provides the ambient container for this application. If your
/// framework defines such an ambient container, use ServiceLocator.Current
/// to get it.
/// </summary>
public static class ServiceLocator
{
private static ServiceLocatorProvider currentProvider;
/// <summary>
/// The current ambient container.
/// </summary>
public static IServiceLocator Current
{
get { return currentProvider(); }
}
/// <summary>
/// Set the delegate that is used to retrieve the current container.
/// </summary>
/// <param name="newProvider">Delegate that, when called, will return
/// the current ambient container.</param>
public static void SetLocatorProvider(ServiceLocatorProvider newProvider)
{
currentProvider = newProvider;
}
}
}
最佳答案
是的,“ambient”应该意味着“共享,所有人都可以使用”。
如果您需要来自 DI 周围某处的引用,请搜索“环境上下文”模式,例如在 Mark Seemann 的“.NET 中的依赖注入(inject)”一书中进行了描述。
关于c# - CommonServiceLocator 的这条评论中的环境一词是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10235461/
我想猜测“环境容器”与它是一个静态类这一事实有关,但这只是一个猜测。 或者这是指标准模式? (也就是说,我真的需要从头到尾读完那本 GoF 书) namespace Microsoft.Practic
目前当我需要向基类中注入(inject)依赖时,我使用下面的代码: public class BaseClass { readonly IService _service; publi
我有一个基于 sharp-architecture 的网络应用程序框架。它实际上将 NHibernate 用于 dal,并且我在 (VIEW-CONTROLLER) 和 DAL 之间添加了一个服务层。
我喜欢在我的 Visual Studio Community 2015 项目中包含 CommonServiceLocator.MefAdapter。当我尝试安装包时:https://www.nuget
我尝试运行以下代码: using System.Web.Http; using System.Web.Mvc; using Conduit.Mam.ClientSerivces.Dal.Configu
我是一名优秀的程序员,十分优秀!