2 // System.Diagnostics.EventLogEntry.cs
5 // Jonathan Pryor (jonpryor@vt.edu)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.ComponentModel;
34 using System.Runtime.InteropServices;
35 using System.Runtime.Serialization;
36 using System.Security.Permissions;
38 namespace System.Diagnostics
42 [ToolboxItem (false), DesignTimeVisible (false)]
43 [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
44 public sealed class EventLogEntry : Component, ISerializable
47 private string category;
48 private short categoryNumber;
50 private EventLogEntryType entryType;
53 private string machineName;
54 private string message;
55 private string[] replacementStrings;
56 private string source;
57 private DateTime timeGenerated;
58 private DateTime timeWritten;
59 private string userName;
60 private long instanceId;
62 internal EventLogEntry (string category, short categoryNumber, int index,
63 int eventID, string source, string message, string userName,
64 string machineName, EventLogEntryType entryType,
65 DateTime timeGenerated, DateTime timeWritten, byte[] data,
66 string[] replacementStrings, long instanceId)
68 this.category = category;
69 this.categoryNumber = categoryNumber;
71 this.entryType = entryType;
72 this.eventID = eventID;
74 this.machineName = machineName;
75 this.message = message;
76 this.replacementStrings = replacementStrings;
78 this.timeGenerated = timeGenerated;
79 this.timeWritten = timeWritten;
80 this.userName = userName;
81 this.instanceId = instanceId;
85 private EventLogEntry (SerializationInfo info, StreamingContext context)
89 [MonitoringDescription ("The category of this event entry.")]
90 public string Category {
91 get { return category; }
94 [MonitoringDescription ("An ID for the category of this event entry.")]
95 public short CategoryNumber {
96 get { return categoryNumber; }
99 [MonitoringDescription ("Binary data associated with this event entry.")]
104 [MonitoringDescription ("The type of this event entry.")]
105 public EventLogEntryType EntryType {
106 get { return entryType; }
109 [Obsolete ("Use InstanceId")]
110 [MonitoringDescription ("An ID number for this event entry.")]
112 get { return eventID; }
115 [MonitoringDescription ("Sequence numer of this event entry.")]
117 get { return index; }
121 [MonitoringDescription ("The instance ID for this event entry.")]
122 public long InstanceId {
123 get { return instanceId; }
126 [MonitoringDescription ("The Computer on which this event entry occured.")]
127 public string MachineName {
128 get { return machineName; }
131 [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
132 [MonitoringDescription ("The message of this event entry.")]
133 public string Message {
134 get { return message; }
137 [MonitoringDescription ("Application strings for this event entry.")]
138 public string[] ReplacementStrings {
139 get { return replacementStrings; }
142 [MonitoringDescription ("The source application of this event entry.")]
143 public string Source {
144 get { return source; }
147 [MonitoringDescription ("Generation time of this event entry.")]
148 public DateTime TimeGenerated {
149 get { return timeGenerated; }
152 [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
153 public DateTime TimeWritten {
154 get { return timeWritten; }
157 [MonitoringDescription ("The name of a user associated with this event entry.")]
158 public string UserName {
159 get { return userName; }
162 public bool Equals (EventLogEntry otherEntry)
164 if (otherEntry == this)
168 (otherEntry.Category == category) &&
169 (otherEntry.CategoryNumber == categoryNumber) &&
170 (otherEntry.Data.Equals (data)) &&
171 (otherEntry.EntryType == entryType) &&
172 (otherEntry.EventID == eventID) &&
173 (otherEntry.Index == index) &&
174 (otherEntry.MachineName == machineName) &&
175 (otherEntry.Message == message) &&
176 (otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
177 (otherEntry.Source == source) &&
178 (otherEntry.TimeGenerated.Equals (timeGenerated)) &&
179 (otherEntry.TimeWritten.Equals (timeWritten)) &&
180 (otherEntry.UserName == userName)
184 [MonoTODO ("Needs serialization support")]
185 void ISerializable.GetObjectData (SerializationInfo info,
186 StreamingContext context)
188 throw new NotImplementedException ();