我试图弄清楚如何摩尔
Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator
因为我试图使用
Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToDeveloperTrace
一些帮助或例子?
我试图弄清楚如何摩尔
Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator
因为我试图使用
Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToDeveloperTrace
一些帮助或例子?
我自己使用 SharePointServiceLocator 找到了一个解决方案。基本上我在我的代码上实现了这个:
var replaceLocator = new ActivatingServiceLocator ( );
SharePointServiceLocator.ReplaceCurrentServiceLocator ( replaceLocator );
replaceLocator.RegisterTypeMapping < ILogger, MockLogger > ( InstantiationType.AsSingleton );
replaceLocator.RegisterTypeMapping < ITraceLogger, MockLogger > ( InstantiationType.AsSingleton );
replaceLocator.RegisterTypeMapping < IEventLogLogger, MockLogger > ( InstantiationType.AsSingleton );