本文整理汇总了C#中Factory.InstantiateLogger方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.InstantiateLogger方法的具体用法?C# Factory.InstantiateLogger怎么用?C# Factory.InstantiateLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory.InstantiateLogger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseUserLocatorFirstForInstances
public void UseUserLocatorFirstForInstances()
{
var loggerMock = new Mock<ILogger>();
var userLocatorMock = new Mock<IServiceLocator>();
userLocatorMock.Setup(ul => ul.GetInstance<ILogger>()).Returns(loggerMock.Object);
var providerLocatorMock = new Mock<IServiceLocator>();
var factory = new Factory(providerLocatorMock.Object, userLocatorMock.Object);
factory.InstantiateLogger();
userLocatorMock.Verify(ul => ul.GetInstance<ILogger>(), Times.Once());
providerLocatorMock.Verify(pl => pl.GetInstance<ILogger>(), Times.Never());
}
示例2: CascadeFromUserLocatorToProviderLocatorForSingleInstance
public void CascadeFromUserLocatorToProviderLocatorForSingleInstance()
{
var sequence = 0;
var loggerMock = new Mock<ILogger>();
var userLocatorMock = new Mock<IServiceLocator>();
userLocatorMock.Setup(ul => ul.GetInstance<ILogger>()).Returns<ILogger>(null).Callback(()=>Assert.Equal(0, sequence++));
var providerLocatorMock = new Mock<IServiceLocator>();
providerLocatorMock.Setup(pl => pl.GetInstance<ILogger>()).Returns(loggerMock.Object).Callback(()=>Assert.Equal(1, sequence++));
var factory = new Factory(providerLocatorMock.Object, userLocatorMock.Object);
factory.InstantiateLogger();
userLocatorMock.Verify(ul=>ul.GetInstance<ILogger>(), Times.Once());
providerLocatorMock.Verify(pl=>pl.GetInstance<ILogger>(), Times.Once());
}
示例3: ReuseExistingLogger
public void ReuseExistingLogger()
{
var logger = new NullLogger();
var locatorMock = new Mock<IServiceLocator>();
locatorMock.Setup(l => l.GetInstance<ILogger>()).Returns(logger);
var factory = new Factory(locatorMock.Object);
var first = factory.InstantiateLogger();
var second = factory.InstantiateLogger();
Assert.Equal(logger, first);
Assert.Equal(logger, second);
locatorMock.Verify(l=>l.GetInstance<ILogger>(), Times.AtMostOnce());
}
示例4: InstantiateNLogLogger
public void InstantiateNLogLogger()
{
var factory = new Factory();
factory.Configuration = new Section { Logging = { Level = LoggingLevel.Warn } };
var result = factory.InstantiateLogger();
Assert.NotNull(result as NLogLogger);
}
示例5: InstantiateLoggerWithIServiceLocator
public void InstantiateLoggerWithIServiceLocator()
{
var loggerMock = new Mock<ILogger>();
var locatorMock = new Mock<IServiceLocator>();
locatorMock.Setup(lm => lm.GetInstance<ILogger>()).Returns(loggerMock.Object);
var factory = new Factory(locatorMock.Object);
var result = factory.InstantiateLogger();
locatorMock.Verify(lm=>lm.GetInstance<ILogger>(), Times.Once());
Assert.Equal(loggerMock.Object, result);
}
示例6: GetRuntime
private IGlimpseRuntime GetRuntime(NancyContext context)
{
IGlimpseRuntime runtime;
if (context.TryGetGlimpseRuntime(out runtime)) return runtime;
var serviceLocator = new NancyServiceLocator(context);
serviceLocator.Tabs = this.tabs;
serviceLocator.Displays = this.displays;
var factory = new Factory(serviceLocator);
serviceLocator.Logger = factory.InstantiateLogger();
runtime = factory.InstantiateRuntime();
runtime.Initialize();
context.SetGlimpseRuntime(runtime);
context.SetGlimpseFactory(factory);
return runtime;
}