2
0

EventLogEntry.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.ComponentModel;
  32. #if NET_2_0
  33. using System.Runtime.InteropServices;
  34. #endif
  35. using System.Runtime.Serialization;
  36. using System.Security.Permissions;
  37. namespace System.Diagnostics
  38. {
  39. [Serializable]
  40. [ToolboxItem (false), DesignTimeVisible (false)]
  41. [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
  42. public sealed class EventLogEntry : Component, ISerializable
  43. {
  44. private string category;
  45. private short categoryNumber;
  46. private byte[] data;
  47. private EventLogEntryType entryType;
  48. private int eventID;
  49. private int index;
  50. private string machineName;
  51. private string message;
  52. private string[] replacementStrings;
  53. private string source;
  54. private DateTime timeGenerated;
  55. private DateTime timeWritten;
  56. private string userName;
  57. #if NET_2_0
  58. private long instanceId;
  59. #endif
  60. internal EventLogEntry (string category, short categoryNumber, int index,
  61. int eventID, string source, string message, string userName,
  62. string machineName, EventLogEntryType entryType,
  63. DateTime timeGenerated, DateTime timeWritten, byte[] data,
  64. string[] replacementStrings, long instanceId)
  65. {
  66. this.category = category;
  67. this.categoryNumber = categoryNumber;
  68. this.data = data;
  69. this.entryType = entryType;
  70. this.eventID = eventID;
  71. this.index = index;
  72. this.machineName = machineName;
  73. this.message = message;
  74. this.replacementStrings = replacementStrings;
  75. this.source = source;
  76. this.timeGenerated = timeGenerated;
  77. this.timeWritten = timeWritten;
  78. this.userName = userName;
  79. #if NET_2_0
  80. this.instanceId = instanceId;
  81. #endif
  82. }
  83. [MonoTODO]
  84. private EventLogEntry (SerializationInfo info, StreamingContext context)
  85. {
  86. }
  87. [MonitoringDescription ("The category of this event entry.")]
  88. public string Category {
  89. get { return category; }
  90. }
  91. [MonitoringDescription ("An ID for the category of this event entry.")]
  92. public short CategoryNumber {
  93. get { return categoryNumber; }
  94. }
  95. [MonitoringDescription ("Binary data associated with this event entry.")]
  96. public byte[] Data {
  97. get { return data; }
  98. }
  99. [MonitoringDescription ("The type of this event entry.")]
  100. public EventLogEntryType EntryType {
  101. get { return entryType; }
  102. }
  103. #if NET_2_0
  104. [Obsolete ("Use InstanceId")]
  105. #endif
  106. [MonitoringDescription ("An ID number for this event entry.")]
  107. public int EventID {
  108. get { return eventID; }
  109. }
  110. [MonitoringDescription ("Sequence numer of this event entry.")]
  111. public int Index {
  112. get { return index; }
  113. }
  114. #if NET_2_0
  115. [ComVisible (false)]
  116. public long InstanceId {
  117. get { return instanceId; }
  118. }
  119. #endif
  120. [MonitoringDescription ("The Computer on which this event entry occured.")]
  121. public string MachineName {
  122. get { return machineName; }
  123. }
  124. [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  125. [MonitoringDescription ("The message of this event entry.")]
  126. public string Message {
  127. get { return message; }
  128. }
  129. [MonitoringDescription ("Application strings for this event entry.")]
  130. public string[] ReplacementStrings {
  131. get { return replacementStrings; }
  132. }
  133. [MonitoringDescription ("The source application of this event entry.")]
  134. public string Source {
  135. get { return source; }
  136. }
  137. [MonitoringDescription ("Generation time of this event entry.")]
  138. public DateTime TimeGenerated {
  139. get { return timeGenerated; }
  140. }
  141. [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
  142. public DateTime TimeWritten {
  143. get { return timeWritten; }
  144. }
  145. [MonitoringDescription ("The name of a user associated with this event entry.")]
  146. public string UserName {
  147. get { return userName; }
  148. }
  149. public bool Equals (EventLogEntry otherEntry)
  150. {
  151. if (otherEntry == this)
  152. return true;
  153. return (
  154. (otherEntry.Category == category) &&
  155. (otherEntry.CategoryNumber == categoryNumber) &&
  156. (otherEntry.Data.Equals (data)) &&
  157. (otherEntry.EntryType == entryType) &&
  158. (otherEntry.EventID == eventID) &&
  159. (otherEntry.Index == index) &&
  160. (otherEntry.MachineName == machineName) &&
  161. (otherEntry.Message == message) &&
  162. (otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
  163. (otherEntry.Source == source) &&
  164. (otherEntry.TimeGenerated.Equals (timeGenerated)) &&
  165. (otherEntry.TimeWritten.Equals (timeWritten)) &&
  166. (otherEntry.UserName == userName)
  167. );
  168. }
  169. [MonoTODO ("Needs serialization support")]
  170. void ISerializable.GetObjectData (SerializationInfo info,
  171. StreamingContext context)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. }
  176. }