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;
35 using System.Runtime.InteropServices;
37 using System.Runtime.Serialization;
38 using System.Security.Permissions;
40 namespace System.Diagnostics
44 [ToolboxItem (false), DesignTimeVisible (false)]
45 [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
46 public sealed class EventLogEntry : Component, ISerializable
49 private string category;
50 private short categoryNumber;
52 private EventLogEntryType entryType;
55 private string machineName;
56 private string message;
57 private string[] replacementStrings;
58 private string source;
59 private DateTime timeGenerated;
60 private DateTime timeWritten;
61 private string userName;
63 private long instanceId;
66 internal EventLogEntry (string category, short categoryNumber, int index,
67 int eventID, string source, string message, string userName,
68 string machineName, EventLogEntryType entryType,
69 DateTime timeGenerated, DateTime timeWritten, byte[] data,
70 string[] replacementStrings, long instanceId)
72 this.category = category;
73 this.categoryNumber = categoryNumber;
75 this.entryType = entryType;
76 this.eventID = eventID;
78 this.machineName = machineName;
79 this.message = message;
80 this.replacementStrings = replacementStrings;
82 this.timeGenerated = timeGenerated;
83 this.timeWritten = timeWritten;
84 this.userName = userName;
86 this.instanceId = instanceId;
91 private EventLogEntry (SerializationInfo info, StreamingContext context)
95 [MonitoringDescription ("The category of this event entry.")]
96 public string Category {
97 get { return category; }
100 [MonitoringDescription ("An ID for the category of this event entry.")]
101 public short CategoryNumber {
102 get { return categoryNumber; }
105 [MonitoringDescription ("Binary data associated with this event entry.")]
110 [MonitoringDescription ("The type of this event entry.")]
111 public EventLogEntryType EntryType {
112 get { return entryType; }
116 [Obsolete ("Use InstanceId")]
118 [MonitoringDescription ("An ID number for this event entry.")]
120 get { return eventID; }
123 [MonitoringDescription ("Sequence numer of this event entry.")]
125 get { return index; }
130 public long InstanceId {
131 get { return instanceId; }
135 [MonitoringDescription ("The Computer on which this event entry occured.")]
136 public string MachineName {
137 get { return machineName; }
140 [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
141 [MonitoringDescription ("The message of this event entry.")]
142 public string Message {
143 get { return message; }
146 [MonitoringDescription ("Application strings for this event entry.")]
147 public string[] ReplacementStrings {
148 get { return replacementStrings; }
151 [MonitoringDescription ("The source application of this event entry.")]
152 public string Source {
153 get { return source; }
156 [MonitoringDescription ("Generation time of this event entry.")]
157 public DateTime TimeGenerated {
158 get { return timeGenerated; }
161 [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
162 public DateTime TimeWritten {
163 get { return timeWritten; }
166 [MonitoringDescription ("The name of a user associated with this event entry.")]
167 public string UserName {
168 get { return userName; }
171 public bool Equals (EventLogEntry otherEntry)
173 if (otherEntry == this)
177 (otherEntry.Category == category) &&
178 (otherEntry.CategoryNumber == categoryNumber) &&
179 (otherEntry.Data.Equals (data)) &&
180 (otherEntry.EntryType == entryType) &&
181 (otherEntry.EventID == eventID) &&
182 (otherEntry.Index == index) &&
183 (otherEntry.MachineName == machineName) &&
184 (otherEntry.Message == message) &&
185 (otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
186 (otherEntry.Source == source) &&
187 (otherEntry.TimeGenerated.Equals (timeGenerated)) &&
188 (otherEntry.TimeWritten.Equals (timeWritten)) &&
189 (otherEntry.UserName == userName)
193 [MonoTODO ("Needs serialization support")]
194 void ISerializable.GetObjectData (SerializationInfo info,
195 StreamingContext context)
197 throw new NotImplementedException ();