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 [MonitoringDescription ("The instance ID for this event entry.")]
131 public long InstanceId
{
132 get { return instanceId; }
136 [MonitoringDescription ("The Computer on which this event entry occured.")]
137 public string MachineName
{
138 get { return machineName; }
141 [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts
.AssemblySystem_Design
, "System.Drawing.Design.UITypeEditor, " + Consts
.AssemblySystem_Drawing
)]
142 [MonitoringDescription ("The message of this event entry.")]
143 public string Message
{
144 get { return message; }
147 [MonitoringDescription ("Application strings for this event entry.")]
148 public string[] ReplacementStrings
{
149 get { return replacementStrings; }
152 [MonitoringDescription ("The source application of this event entry.")]
153 public string Source
{
154 get { return source; }
157 [MonitoringDescription ("Generation time of this event entry.")]
158 public DateTime TimeGenerated
{
159 get { return timeGenerated; }
162 [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
163 public DateTime TimeWritten
{
164 get { return timeWritten; }
167 [MonitoringDescription ("The name of a user associated with this event entry.")]
168 public string UserName
{
169 get { return userName; }
172 public bool Equals (EventLogEntry otherEntry
)
174 if (otherEntry
== this)
178 (otherEntry
.Category
== category
) &&
179 (otherEntry
.CategoryNumber
== categoryNumber
) &&
180 (otherEntry
.Data
.Equals (data
)) &&
181 (otherEntry
.EntryType
== entryType
) &&
182 (otherEntry
.EventID
== eventID
) &&
183 (otherEntry
.Index
== index
) &&
184 (otherEntry
.MachineName
== machineName
) &&
185 (otherEntry
.Message
== message
) &&
186 (otherEntry
.ReplacementStrings
.Equals (replacementStrings
)) &&
187 (otherEntry
.Source
== source
) &&
188 (otherEntry
.TimeGenerated
.Equals (timeGenerated
)) &&
189 (otherEntry
.TimeWritten
.Equals (timeWritten
)) &&
190 (otherEntry
.UserName
== userName
)
194 [MonoTODO ("Needs serialization support")]
195 void ISerializable
.GetObjectData (SerializationInfo info
,
196 StreamingContext context
)
198 throw new NotImplementedException ();