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.
34 using System
.ComponentModel
;
35 using System
.Diagnostics
;
36 using System
.Runtime
.Serialization
;
38 namespace System
.Diagnostics
42 [ToolboxItem (false), DesignTimeVisible (false)]
43 public sealed class EventLogEntry
: Component
, ISerializable
46 private string category
;
47 private short categoryNumber
;
49 private EventLogEntryType entryType
;
52 private string machineName
;
53 private string message
;
54 private string[] replacementStrings
;
55 private string source
;
56 private DateTime timeGenerated
;
57 private DateTime timeWritten
;
58 private string userName
;
60 internal EventLogEntry (string category
, short categoryNumber
, int index
,
61 int eventID
, string message
, string source
,
62 string userName
, string machineName
, EventLogEntryType entryType
,
63 DateTime timeGenerated
, DateTime timeWritten
, byte[] data
,
64 string[] replacementStrings
)
66 this.category
= category
;
67 this.categoryNumber
= categoryNumber
;
69 this.entryType
= entryType
;
70 this.eventID
= eventID
;
72 this.machineName
= machineName
;
73 this.message
= message
;
74 this.replacementStrings
= replacementStrings
;
76 this.timeGenerated
= timeGenerated
;
77 this.timeWritten
= timeWritten
;
78 this.userName
= userName
;
82 private EventLogEntry (SerializationInfo info
, StreamingContext context
)
86 [MonitoringDescription ("The category of this event entry.")]
87 public string Category
{
88 get { return category; }
91 [MonitoringDescription ("An ID for the category of this event entry.")]
92 public short CategoryNumber
{
93 get { return categoryNumber; }
96 [MonitoringDescription ("Binary data associated with this event entry.")]
101 [MonitoringDescription ("The type of this event entry.")]
102 public EventLogEntryType EntryType
{
103 get { return entryType; }
106 [MonitoringDescription ("An ID number for this event entry.")]
108 get { return eventID; }
111 [MonitoringDescription ("Sequence numer of this event entry.")]
113 get { return index; }
116 [MonitoringDescription ("The Computer on which this event entry occured.")]
117 public string MachineName
{
118 get { return machineName; }
121 [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts
.AssemblySystem_Design
, "System.Drawing.Design.UITypeEditor, " + Consts
.AssemblySystem_Drawing
)]
122 [MonitoringDescription ("The message of this event entry.")]
123 public string Message
{
124 get { return message; }
127 [MonitoringDescription ("Application strings for this event entry.")]
128 public string[] ReplacementStrings
{
129 get { return replacementStrings; }
132 [MonitoringDescription ("The source application of this event entry.")]
133 public string Source
{
134 get { return source; }
137 [MonitoringDescription ("Generation time of this event entry.")]
138 public DateTime TimeGenerated
{
139 get { return timeGenerated; }
142 [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
143 public DateTime TimeWritten
{
144 get { return timeWritten; }
147 [MonitoringDescription ("The name of a user associated with this event entry.")]
148 public string UserName
{
149 get { return userName; }
152 public bool Equals (EventLogEntry otherEntry
)
154 if (otherEntry
== this)
158 (otherEntry
.Category
== category
) &&
159 (otherEntry
.CategoryNumber
== categoryNumber
) &&
160 (otherEntry
.Data
.Equals (data
)) &&
161 (otherEntry
.EntryType
== entryType
) &&
162 (otherEntry
.EventID
== eventID
) &&
163 (otherEntry
.Index
== index
) &&
164 (otherEntry
.MachineName
== machineName
) &&
165 (otherEntry
.Message
== message
) &&
166 (otherEntry
.ReplacementStrings
.Equals (replacementStrings
)) &&
167 (otherEntry
.Source
== source
) &&
168 (otherEntry
.TimeGenerated
.Equals (timeGenerated
)) &&
169 (otherEntry
.TimeWritten
.Equals (timeWritten
)) &&
170 (otherEntry
.UserName
== userName
)
174 [MonoTODO ("Needs serialization support")]
175 void ISerializable
.GetObjectData (SerializationInfo info
,
176 StreamingContext context
)
178 throw new NotImplementedException ();