当前位置: 首页>>代码示例>>C#>>正文


C# Factory.InstantiateLogger方法代码示例

本文整理汇总了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());
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:14,代码来源:FactoryShould.cs

示例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());
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:16,代码来源:FactoryShould.cs

示例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());
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:15,代码来源:FactoryShould.cs

示例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);
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:8,代码来源:FactoryShould.cs

示例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);
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:12,代码来源:FactoryShould.cs

示例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;
        }
开发者ID:richardprice,项目名称:Glimpse.Nancy,代码行数:17,代码来源:GlimpseStartup.cs


注:本文中的Factory.InstantiateLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。