2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / class / System / System.Diagnostics / EventLogEntry.cs
blob5dd34c9f99a7174c290f1b885ae814c261a2eb64
1 //
2 // System.Diagnostics.EventLogEntry.cs
3 //
4 // Authors:
5 // Jonathan Pryor (jonpryor@vt.edu)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) 2002
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:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
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 #if NET_2_0
35 using System.Runtime.InteropServices;
36 #endif
37 using System.Runtime.Serialization;
38 using System.Security.Permissions;
40 namespace System.Diagnostics
43 [Serializable]
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;
51 private byte[] data;
52 private EventLogEntryType entryType;
53 private int eventID;
54 private int index;
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;
62 #if NET_2_0
63 private long instanceId;
64 #endif
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;
74 this.data = data;
75 this.entryType = entryType;
76 this.eventID = eventID;
77 this.index = index;
78 this.machineName = machineName;
79 this.message = message;
80 this.replacementStrings = replacementStrings;
81 this.source = source;
82 this.timeGenerated = timeGenerated;
83 this.timeWritten = timeWritten;
84 this.userName = userName;
85 #if NET_2_0
86 this.instanceId = instanceId;
87 #endif
90 [MonoTODO]
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.")]
106 public byte[] Data {
107 get { return data; }
110 [MonitoringDescription ("The type of this event entry.")]
111 public EventLogEntryType EntryType {
112 get { return entryType; }
115 #if NET_2_0
116 [Obsolete ("Use InstanceId")]
117 #endif
118 [MonitoringDescription ("An ID number for this event entry.")]
119 public int EventID {
120 get { return eventID; }
123 [MonitoringDescription ("Sequence numer of this event entry.")]
124 public int Index {
125 get { return index; }
128 #if NET_2_0
129 [ComVisible (false)]
130 [MonitoringDescription ("The instance ID for this event entry.")]
131 public long InstanceId {
132 get { return instanceId; }
134 #endif
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)
175 return true;
177 return (
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 ();