我试图找出如何骚扰
Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator
因为我试图使用
Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToDeveloperTrace
一些帮助或示例?
答案 0 :(得分:2)
我自己使用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 );