我正在尝试创建IPersistenceStore
的新实现。
我理解我需要使用IServiceLocator
注册我的新实现,web.config
在<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd" serviceLocatorType="MyNewServiceLocator, MyAssembly">
的glimpse节点中配置,如下所示:
GetInstance
但是,我看到以下行为:
IServiceLocator
的{{1}}方法永远不会被点击IPersistenceStore
的ctor在应用启动时被点击IPersistenceStore
上没有其他任何方法被击中(即Glimpse数据仍然存储在IPersistenceStore
的默认impl中)我的IPersistenceStore
似乎没有正确注册。为什么会这样?
答案 0 :(得分:1)
目前尚不清楚可能出现的问题,因为您没有显示与IServiceLocator
相关的任何代码
这些行中的某些内容应该足以让您的自定义服务定位器返回自定义持久性存储:
public class MyNewServiceLocator : IServiceLocator
{
public T GetInstance<T>() where T : class
{
var type = typeof(T);
if (type == typeof(IPersistenceStore))
{
return new CustomPersistenceStore() as T;
}
return null;
}
public ICollection<T> GetAllInstances<T>() where T : class
{
return null;
}
}