PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
C# | 33 lines | 25 code | 5 blank | 3 comment | 3 complexity | f6d95d11ffa01109845576370a08541c MD5 | raw file
 1//------------------------------------------------------------
 2// Copyright (c) Microsoft Corporation.  All rights reserved.
 3//------------------------------------------------------------
 4
 5namespace Microsoft.Server.Common.Diagnostics
 6{
 7    using System.Collections;
 8    using System.Xml;
 9
10    class DictionaryTraceRecord : TraceRecord
11    {
12        IDictionary dictionary;
13
14        public DictionaryTraceRecord(IDictionary dictionary)
15        {
16            this.dictionary = dictionary;
17        }
18
19        public override string EventId { get { return TraceRecord.EventIdBase + "Dictionary" + TraceRecord.NamespaceSuffix; } }
20
21        public override void WriteTo(XmlWriter xml)
22        {
23            if (this.dictionary != null)
24            {
25                foreach (object key in this.dictionary.Keys)
26                {
27                    object value = this.dictionary[key];
28                    xml.WriteElementString(key.ToString(), value == null ? string.Empty : value.ToString());
29                }
30            }
31        }
32    }
33}