EventLogEntry.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // System.Diagnostics.EventLogEntry.cs
  3. //
  4. // Authors:
  5. // Jonathan Pryor ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2002
  9. // (C) 2003 Andreas Nahr
  10. //
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.ComponentModel;
  33. using System.Diagnostics;
  34. using System.Runtime.Serialization;
  35. namespace System.Diagnostics
  36. {
  37. [Serializable]
  38. [ToolboxItem (false), DesignTimeVisible (false)]
  39. public sealed class EventLogEntry : Component, ISerializable
  40. {
  41. private string category;
  42. private short categoryNumber;
  43. private byte[] data;
  44. private EventLogEntryType entryType;
  45. private int eventID;
  46. private int index;
  47. private string machineName;
  48. private string message;
  49. private string[] replacementStrings;
  50. private string source;
  51. private DateTime timeGenerated;
  52. private DateTime timeWritten;
  53. private string userName;
  54. internal EventLogEntry (string category, short categoryNumber, int index,
  55. int eventID, string message, string source,
  56. string userName, string machineName, EventLogEntryType entryType,
  57. DateTime timeGenerated, DateTime timeWritten, byte[] data,
  58. string[] replacementStrings)
  59. {
  60. this.category = category;
  61. this.categoryNumber = categoryNumber;
  62. this.data = data;
  63. this.entryType = entryType;
  64. this.eventID = eventID;
  65. this.index = index;
  66. this.machineName = machineName;
  67. this.message = message;
  68. this.replacementStrings = replacementStrings;
  69. this.source = source;
  70. this.timeGenerated = timeGenerated;
  71. this.timeWritten = timeWritten;
  72. this.userName = userName;
  73. }
  74. [MonoTODO]
  75. private EventLogEntry (SerializationInfo info, StreamingContext context)
  76. {
  77. }
  78. [MonitoringDescription ("The category of this event entry.")]
  79. public string Category {
  80. get { return category; }
  81. }
  82. [MonitoringDescription ("An ID for the category of this event entry.")]
  83. public short CategoryNumber {
  84. get { return categoryNumber; }
  85. }
  86. [MonitoringDescription ("Binary data associated with this event entry.")]
  87. public byte[] Data {
  88. get { return data; }
  89. }
  90. [MonitoringDescription ("The type of this event entry.")]
  91. public EventLogEntryType EntryType {
  92. get { return entryType; }
  93. }
  94. [MonitoringDescription ("An ID number for this event entry.")]
  95. public int EventID {
  96. get { return eventID; }
  97. }
  98. [MonitoringDescription ("Sequence numer of this event entry.")]
  99. public int Index {
  100. get { return index; }
  101. }
  102. [MonitoringDescription ("The Computer on which this event entry occured.")]
  103. public string MachineName {
  104. get { return machineName; }
  105. }
  106. [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  107. [MonitoringDescription ("The message of this event entry.")]
  108. public string Message {
  109. get { return message; }
  110. }
  111. [MonitoringDescription ("Application strings for this event entry.")]
  112. public string[] ReplacementStrings {
  113. get { return replacementStrings; }
  114. }
  115. [MonitoringDescription ("The source application of this event entry.")]
  116. public string Source {
  117. get { return source; }
  118. }
  119. [MonitoringDescription ("Generation time of this event entry.")]
  120. public DateTime TimeGenerated {
  121. get { return timeGenerated; }
  122. }
  123. [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
  124. public DateTime TimeWritten {
  125. get { return timeWritten; }
  126. }
  127. [MonitoringDescription ("The name of a user associated with this event entry.")]
  128. public string UserName {
  129. get { return userName; }
  130. }
  131. public bool Equals (EventLogEntry otherEntry)
  132. {
  133. if (otherEntry == this)
  134. return true;
  135. return (
  136. (otherEntry.Category == category) &&
  137. (otherEntry.CategoryNumber == categoryNumber) &&
  138. (otherEntry.Data.Equals (data)) &&
  139. (otherEntry.EntryType == entryType) &&
  140. (otherEntry.EventID == eventID) &&
  141. (otherEntry.Index == index) &&
  142. (otherEntry.MachineName == machineName) &&
  143. (otherEntry.Message == message) &&
  144. (otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
  145. (otherEntry.Source == source) &&
  146. (otherEntry.TimeGenerated.Equals (timeGenerated)) &&
  147. (otherEntry.TimeWritten.Equals (timeWritten)) &&
  148. (otherEntry.UserName == userName)
  149. );
  150. }
  151. [MonoTODO ("Needs serialization support")]
  152. void ISerializable.GetObjectData (SerializationInfo info,
  153. StreamingContext context)
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. }
  158. }