Merge pull request #4222 from alexanderkyte/fix_mismatch_com_disabled
[mono.git] / mcs / class / System / System.Diagnostics / EventLogEntry.cs
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
10 //
11
12 //
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.
31 //
32
33 using System.ComponentModel;
34 using System.Runtime.InteropServices;
35 using System.Runtime.Serialization;
36 using System.Security.Permissions;
37
38 namespace System.Diagnostics
39 {
40
41         [Serializable]
42         [ToolboxItem (false), DesignTimeVisible (false)]
43         [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
44         public sealed class EventLogEntry : Component, ISerializable
45         {
46
47                 private string category;
48                 private short categoryNumber;
49                 private byte[] data;
50                 private EventLogEntryType entryType;
51                 private int eventID;
52                 private int index;
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;
61
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)
67                 {
68                         this.category = category;
69                         this.categoryNumber = categoryNumber;
70                         this.data = data;
71                         this.entryType = entryType;
72                         this.eventID = eventID;
73                         this.index = index;
74                         this.machineName = machineName;
75                         this.message = message;
76                         this.replacementStrings = replacementStrings;
77                         this.source = source;
78                         this.timeGenerated = timeGenerated;
79                         this.timeWritten = timeWritten;
80                         this.userName = userName;
81                         this.instanceId = instanceId;
82                 }
83
84                 [MonoTODO]
85                 private EventLogEntry (SerializationInfo info, StreamingContext context)
86                 {
87                 }
88
89                 [MonitoringDescription ("The category of this event entry.")]
90                 public string Category {
91                         get { return category; }
92                 }
93
94                 [MonitoringDescription ("An ID for the category of this event entry.")]
95                 public short CategoryNumber {
96                         get { return categoryNumber; }
97                 }
98
99                 [MonitoringDescription ("Binary data associated with this event entry.")]
100                 public byte[] Data {
101                         get { return data; }
102                 }
103
104                 [MonitoringDescription ("The type of this event entry.")]
105                 public EventLogEntryType EntryType {
106                         get { return entryType; }
107                 }
108
109                 [Obsolete ("Use InstanceId")]
110                 [MonitoringDescription ("An ID number for this event entry.")]
111                 public int EventID {
112                         get { return eventID; }
113                 }
114
115                 [MonitoringDescription ("Sequence numer of this event entry.")]
116                 public int Index {
117                         get { return index; }
118                 }
119
120                 [ComVisible (false)]
121                 [MonitoringDescription ("The instance ID for this event entry.")]
122                 public long InstanceId {
123                         get { return instanceId; }
124                 }
125
126                 [MonitoringDescription ("The Computer on which this event entry occured.")]
127                 public string MachineName {
128                         get { return machineName; }
129                 }
130
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; }
135                 }
136
137                 [MonitoringDescription ("Application strings for this event entry.")]
138                 public string[] ReplacementStrings {
139                         get { return replacementStrings; }
140                 }
141
142                 [MonitoringDescription ("The source application of this event entry.")]
143                 public string Source {
144                         get { return source; }
145                 }
146
147                 [MonitoringDescription ("Generation time of this event entry.")]
148                 public DateTime TimeGenerated {
149                         get { return timeGenerated; }
150                 }
151
152                 [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
153                 public DateTime TimeWritten {
154                         get { return timeWritten; }
155                 }
156
157                 [MonitoringDescription ("The name of a user associated with this event entry.")]
158                 public string UserName {
159                         get { return userName; }
160                 }
161
162                 public bool Equals (EventLogEntry otherEntry)
163                 {
164                         if (otherEntry == this)
165                                 return true;
166
167                         return (
168                                 (otherEntry.Category == category) &&
169                                 (otherEntry.CategoryNumber == categoryNumber) &&
170                                 (otherEntry.Data.Equals (data)) &&
171                                 (otherEntry.EntryType == entryType) &&
172                                 (otherEntry.InstanceId == instanceId) &&
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)
181                                 );
182                 }
183
184                 [MonoTODO ("Needs serialization support")]
185                 void ISerializable.GetObjectData (SerializationInfo info, 
186                         StreamingContext context)
187                 {
188                         throw new NotImplementedException ();
189                 }
190         }
191 }
192