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


C# LogWriter.Configure方法代码示例

本文整理汇总了C#中LogWriter.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# LogWriter.Configure方法的具体用法?C# LogWriter.Configure怎么用?C# LogWriter.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogWriter的用法示例。


在下文中一共展示了LogWriter.Configure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReconfigureDoesNotDisposeListenersStillUsedInSpecialSources

        public void ReconfigureDoesNotDisposeListenersStillUsedInSpecialSources()
        {
            var traceListener = new MockDisposableTraceListener();

            var config = new LoggingConfiguration();
            config.AddLogSource("General", traceListener);

            var logWriter = new LogWriter(config);
            logWriter.Configure((cfg) =>
            {
                cfg.LogSources.Clear();

                cfg.AddLogSource("New", new DefaultTraceListener());
                cfg.SpecialSources.AllEvents.Listeners.Add(traceListener);
            });

            Assert.AreEqual(0, traceListener.DisposedCalls);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:18,代码来源:LoggingConfigurationFixture.cs

示例2: ReconfigureDisposesUnusedListeners

        public void ReconfigureDisposesUnusedListeners()
        {
            var traceListener = new MockDisposableTraceListener();

            var config = new LoggingConfiguration();
            config.AddLogSource("General", traceListener);

            var logWriter = new LogWriter(config);
            logWriter.Configure((cfg) =>
            {
                cfg.LogSources.Clear();

                cfg.AddLogSource("New", new DefaultTraceListener());
            });

            Assert.AreEqual(1, traceListener.DisposedCalls);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:17,代码来源:LoggingConfigurationFixture.cs

示例3: ReconfigureTraceEnabled

        public void ReconfigureTraceEnabled()
        {
            var config = new LoggingConfiguration();
            config.IsTracingEnabled = false;

            var logger = new LogWriter(config);

            // Is it false?
            logger.Configure(cfg => Assert.IsFalse(cfg.UseImpersonation));

            // Toggle
            logger.Configure(cfg => cfg.IsTracingEnabled = true);

            // Did it change?
            logger.Configure(cfg => Assert.IsTrue(cfg.IsTracingEnabled));
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:16,代码来源:LoggingConfigurationFixture.cs

示例4: ReconfigureIsLoggingEnabled

        public void ReconfigureIsLoggingEnabled()
        {
            var config = new LoggingConfiguration();

            Assert.IsTrue(config.IsLoggingEnabled);

            var logger = new LogWriter(config);

            Assert.IsTrue(logger.IsLoggingEnabled());

            // Disable logging
            logger.Configure(cfg => cfg.IsLoggingEnabled = false);

            Assert.IsFalse(logger.IsLoggingEnabled());
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:15,代码来源:LoggingConfigurationFixture.cs

示例5: ReconfigureImpersonation

        public void ReconfigureImpersonation()
        {
            var config = new LoggingConfiguration();
            config.UseImpersonation = false;

            var logger = new LogWriter(config);

            // Is it false?
            logger.Configure(cfg => Assert.IsFalse(cfg.UseImpersonation));

            // Use impersonation
            logger.Configure(cfg => cfg.UseImpersonation = true);

            // Did it change?
            logger.Configure(cfg => Assert.IsTrue(cfg.UseImpersonation));
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:16,代码来源:LoggingConfigurationFixture.cs


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