【问题标题】:How to mole SharePointServiceLocator to work with the logger如何让 SharePointServiceLocator 与记录器一起工作
【发布时间】:2013-07-24 13:06:57
【问题描述】:

我想知道怎么搞定

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

因为我尝试使用

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

一些帮助或示例?

【问题讨论】:

    标签: moles pex-and-moles


    【解决方案1】:

    我自己使用 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 );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 2017-06-25
      • 2020-12-13
      • 2012-02-02
      相关资源
      最近更新 更多