LogConfigEventLogSubscriptionOutput.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System.Xml;
  2. namespace Wayne.Lib.Log
  3. {
  4. /// <summary>
  5. /// Event log subscription output
  6. /// </summary>
  7. public class LogConfigEventLogSubscriptionOutput : LogConfigOutput
  8. {
  9. /// <summary>
  10. /// Subscriber ID
  11. /// </summary>
  12. public string SubscriberId { get; set; }
  13. /// <summary>
  14. /// Storage type
  15. /// </summary>
  16. public LogConfigEventLogStorageType StorageType { get; set; }
  17. internal const string XmlType = "EventLogSubscription";
  18. /// <summary>
  19. /// Constructor
  20. /// </summary>
  21. public LogConfigEventLogSubscriptionOutput()
  22. {
  23. }
  24. /// <summary>
  25. /// Constructor
  26. /// </summary>
  27. /// <param name="subscriberId"></param>
  28. /// <param name="storageType"></param>
  29. public LogConfigEventLogSubscriptionOutput(string subscriberId, LogConfigEventLogStorageType storageType)
  30. {
  31. SubscriberId = subscriberId;
  32. StorageType = storageType;
  33. }
  34. /// <summary>
  35. /// Deserialization constructor
  36. /// </summary>
  37. /// <param name="parametersNode"></param>
  38. /// <param name="ns"></param>
  39. internal LogConfigEventLogSubscriptionOutput(XmlNode parametersNode, string ns)
  40. {
  41. XmlNode eventLogParamsNode = parametersNode["EventLogSubscriptionParams", ns];
  42. SubscriberId = eventLogParamsNode.Attributes["SubscriberId"].Value;
  43. StorageType = EnumSupport.Parse(eventLogParamsNode.Attributes["StorageType"].Value, false, LogConfigEventLogStorageType.Volatile);
  44. }
  45. /// <summary>
  46. /// Serialization
  47. /// </summary>
  48. /// <param name="xmlWriter"></param>
  49. internal override void WriteXml(XmlWriter xmlWriter)
  50. {
  51. xmlWriter.WriteStartElement("Output");
  52. xmlWriter.WriteAttributeString("Type", XmlType);
  53. xmlWriter.WriteStartElement("Parameters");
  54. xmlWriter.WriteStartElement("EventLogSubscriptionParams");
  55. xmlWriter.WriteAttributeString("SubscriberId", SubscriberId ?? string.Empty);
  56. xmlWriter.WriteAttributeString("StorageType", StorageType.ToString());
  57. xmlWriter.WriteEndElement(); // EventLogSubscriptionParams
  58. xmlWriter.WriteEndElement(); // Parameters
  59. xmlWriter.WriteEndElement(); // Output
  60. }
  61. /// <summary>
  62. /// Creates a clone object.
  63. /// </summary>
  64. /// <returns></returns>
  65. public override object Clone()
  66. {
  67. return new LogConfigEventLogSubscriptionOutput(SubscriberId, StorageType);
  68. }
  69. }
  70. }