PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.Server.Common/Microsoft/Server/Common/Diagnostics/DiagnosticTraceSource.cs

#
C# | 43 lines | 36 code | 4 blank | 3 comment | 2 complexity | c7e251594d6c3d04ddbe5863ece79f7e MD5 | raw file
 1//-----------------------------------------------------------------------------
 2// Copyright (c) Microsoft Corporation.  All rights reserved.
 3//-----------------------------------------------------------------------------
 4
 5namespace Microsoft.Server.Common.Diagnostics
 6{
 7    using System.Diagnostics;
 8
 9    public class DiagnosticTraceSource : TraceSource
10    {
11        const string PropagateActivityValue = "propagateActivity";
12        public DiagnosticTraceSource(string name)
13            : base(name)
14        {
15        }
16
17        protected override string[] GetSupportedAttributes()
18        {
19            return new string[] { DiagnosticTraceSource.PropagateActivityValue };
20        }
21
22        public bool PropagateActivity
23        {
24            get
25            {
26                bool retval = false;
27                string attributeValue = this.Attributes[DiagnosticTraceSource.PropagateActivityValue];
28                if (!string.IsNullOrEmpty(attributeValue))
29                {
30                    if (!bool.TryParse(attributeValue, out retval))
31                    {
32                        retval = false;
33                    }
34                }
35                return retval;
36            }
37            set
38            {
39                this.Attributes[DiagnosticTraceSource.PropagateActivityValue] = value.ToString();
40            }
41        }
42    }
43}