2013-07-24 35 views
1

我試圖找出如何去痣的如何去痣SharePointServiceLocator與記錄

Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator 

工作,因爲我試圖用

Microsoft.Practices.SharePoint.Common.Logging.SharePointLogger.WriteToDeveloperTrace 

一些幫助或例子嗎?

回答

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);