PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms 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
Possible License(s): CC-BY-SA-3.0, Apache-2.0
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace Microsoft.Server.Common.Diagnostics
  5. {
  6. using System.Collections;
  7. using System.Xml;
  8. class DictionaryTraceRecord : TraceRecord
  9. {
  10. IDictionary dictionary;
  11. public DictionaryTraceRecord(IDictionary dictionary)
  12. {
  13. this.dictionary = dictionary;
  14. }
  15. public override string EventId { get { return TraceRecord.EventIdBase + "Dictionary" + TraceRecord.NamespaceSuffix; } }
  16. public override void WriteTo(XmlWriter xml)
  17. {
  18. if (this.dictionary != null)
  19. {
  20. foreach (object key in this.dictionary.Keys)
  21. {
  22. object value = this.dictionary[key];
  23. xml.WriteElementString(key.ToString(), value == null ? string.Empty : value.ToString());
  24. }
  25. }
  26. }
  27. }
  28. }