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


C# LogWriter.GetMatchingTraceSources方法代码示例

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


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

示例1: CanFindMatchingCategories

        public void CanFindMatchingCategories()
        {
            Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
            traceSources.Add("newcat1", new LogSource("newcat1"));
            traceSources.Add("newcat2", new LogSource("newcat2"));
            traceSources.Add("newcat3", new LogSource("newcat3"));
            traceSources.Add("newcat4", new LogSource("newcat4"));
            LogWriter logWriter = new LogWriter(emptyFilters, traceSources, new LogSource("errors"), "default");

            string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" };
            LogEntry logEntry = new LogEntry();
            logEntry.Categories = categories;
            IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry);

            logWriter.Dispose();

            Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>();
            foreach (LogSource traceSource in matchingTraceSources)
            {
                matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource);
            }

            Assert.AreEqual(2, matchingTraceSourcesDictionary.Count);
            Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0]));
            Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1]));
            Assert.IsFalse(matchingTraceSourcesDictionary.ContainsKey(categories[2]));
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:27,代码来源:LogDistributorFixture.cs

示例2: UsesDefaultTraceSourceIfThereAreMissingCategoriesAndDefaultIsConfiguredAndMandatoryIsNotConfigured

	    public void UsesDefaultTraceSourceIfThereAreMissingCategoriesAndDefaultIsConfiguredAndMandatoryIsNotConfigured()
	    {
	        Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
	        traceSources.Add("newcat1", new LogSource("newcat1"));
	        traceSources.Add("newcat2", new LogSource("newcat2"));
	        traceSources.Add("newcat3", new LogSource("newcat3"));
	        traceSources.Add("newcat4", new LogSource("newcat4"));
	        LogSource mandatoryTraceSource = null;
	        LogSource defaultTraceSource = new LogSource("default");
	        LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All);
	        errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener());
	        LogWriter logWriter =
	            new LogWriter(emptyFilters, traceSources, mandatoryTraceSource, defaultTraceSource, errorsTraceSource, "default", false, false);

	        string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" };
	        LogEntry logEntry = new LogEntry();
	        logEntry.Categories = categories;
	        IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry);

            logWriter.Dispose();
            Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>();
	        foreach (LogSource traceSource in matchingTraceSources)
	        {
	            matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource);
	        }

	        Assert.AreEqual(3, matchingTraceSourcesDictionary.Count);
	        Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0]));
	        Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1]));
	        Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(defaultTraceSource.Name));
	        Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count);
	    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:32,代码来源:LogDistributorFixture.cs

示例3: DoesNotReportMissingCategoriesWhenThereAreNotMissingCategoriesAndDefaultIsNotConfigured

	    public void DoesNotReportMissingCategoriesWhenThereAreNotMissingCategoriesAndDefaultIsNotConfigured()
	    {
	        Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
	        traceSources.Add("newcat1", new LogSource("newcat1"));
	        traceSources.Add("newcat2", new LogSource("newcat2"));
	        traceSources.Add("newcat3", new LogSource("newcat3"));
	        traceSources.Add("newcat4", new LogSource("newcat4"));
	        LogSource errorsTraceSource = new LogSource("errors", SourceLevels.All);
	        errorsTraceSource.Listeners.Add(new ErrorsMockTraceListener());
	        LogWriter logWriter = new LogWriter(emptyFilters, traceSources, emptyTraceSource, emptyTraceSource, errorsTraceSource, "default", false, false);

	        string[] categories = new string[] { "newcat1", "newcat2" };
	        LogEntry logEntry = new LogEntry();
	        logEntry.Categories = categories;
	        IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry);

            logWriter.Dispose();
            Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>();
	        foreach (LogSource traceSource in matchingTraceSources)
	        {
	            matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource);
	        }

	        Assert.AreEqual(2, matchingTraceSourcesDictionary.Count);
	        Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count);
	    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:26,代码来源:LogDistributorFixture.cs

示例4: UsedMandatoryTraceSourceIfAllCategoriesAreMissing

        public void UsedMandatoryTraceSourceIfAllCategoriesAreMissing()
        {
            Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
            traceSources.Add("newcat1", new LogSource("newcat1"));
            traceSources.Add("newcat2", new LogSource("newcat2"));
            traceSources.Add("newcat3", new LogSource("newcat3"));
            traceSources.Add("newcat4", new LogSource("newcat4"));
            LogSource mandatoryTraceSource = new LogSource("mandatory");
            LogSource errorsTraceSource = new LogSource("errors", new[] { new ErrorsMockTraceListener() }, SourceLevels.All);
            LogWriter logWriter = new LogWriter(emptyFilters, traceSources, mandatoryTraceSource, emptyTraceSource, errorsTraceSource, "default", false, false);

            string[] categories = new string[] { "newcat5", "newcat6" };
            LogEntry logEntry = new LogEntry();
            logEntry.Categories = categories;
            IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry);

            logWriter.Dispose();
            Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>();
            foreach (LogSource traceSource in matchingTraceSources)
            {
                matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource);
            }

            Assert.AreEqual(1, matchingTraceSourcesDictionary.Count);
            Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(mandatoryTraceSource.Name));
            Assert.AreEqual(0, ErrorsMockTraceListener.Entries.Count);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:27,代码来源:LogDistributorFixture.cs


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