New test.
[mono.git] / mcs / class / System / System.Diagnostics / EventLogEntry.cs
index 824cd57b4d2c5a9ff7f4fb78f99ed1e289cd5dc2..136cd01fdbd3357f60269942cc9a45ee00bb1581 100644 (file)
 // (C) 2003 Andreas Nahr
 //
 
-using System;
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System.ComponentModel;
-using System.Diagnostics;
+#if NET_2_0
+using System.Runtime.InteropServices;
+#endif
 using System.Runtime.Serialization;
+using System.Security.Permissions;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics
+{
 
        [Serializable]
-       [MonoTODO("Just stubbed out")]
-       [ToolboxItem (""), DesignTimeVisible (false), DesignerCategory ("Category")]
-       public sealed class EventLogEntry : Component, ISerializable {
-
-               [MonoTODO]
-               internal EventLogEntry ()
+       [ToolboxItem (false), DesignTimeVisible (false)]
+       [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+       public sealed class EventLogEntry : Component, ISerializable
+       {
+
+               private string category;
+               private short categoryNumber;
+               private byte[] data;
+               private EventLogEntryType entryType;
+               private int eventID;
+               private int index;
+               private string machineName;
+               private string message;
+               private string[] replacementStrings;
+               private string source;
+               private DateTime timeGenerated;
+               private DateTime timeWritten;
+               private string userName;
+#if NET_2_0
+               private long instanceId;
+#endif
+
+               internal EventLogEntry (string category, short categoryNumber, int index, 
+                                       int eventID, string source, string message, string userName, 
+                                       string machineName, EventLogEntryType entryType, 
+                                       DateTime timeGenerated, DateTime timeWritten, byte[] data, 
+                                       string[] replacementStrings, long instanceId)
+               {
+                       this.category = category;
+                       this.categoryNumber = categoryNumber;
+                       this.data = data;
+                       this.entryType = entryType;
+                       this.eventID = eventID;
+                       this.index = index;
+                       this.machineName = machineName;
+                       this.message = message;
+                       this.replacementStrings = replacementStrings;
+                       this.source = source;
+                       this.timeGenerated = timeGenerated;
+                       this.timeWritten = timeWritten;
+                       this.userName = userName;
+#if NET_2_0
+                       this.instanceId = instanceId;
+#endif
+               }
+
+               [MonoTODO]
+               private EventLogEntry (SerializationInfo info, StreamingContext context)
                {
                }
 
-               [MonoTODO]
                [MonitoringDescription ("The category of this event entry.")]
                public string Category {
-                       get {throw new NotImplementedException ();}
+                       get { return category; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("An ID for the category of this event entry.")]
                public short CategoryNumber {
-                       get {throw new NotImplementedException ();}
+                       get { return categoryNumber; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("Binary data associated with this event entry.")]
                public byte[] Data {
-                       get {throw new NotImplementedException ();}
+                       get { return data; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("The type of this event entry.")]
                public EventLogEntryType EntryType {
-                       get {throw new NotImplementedException ();}
+                       get { return entryType; }
                }
 
-               [MonoTODO]
+#if NET_2_0
+               [Obsolete ("Use InstanceId")]
+#endif
                [MonitoringDescription ("An ID number for this event entry.")]
                public int EventID {
-                       get {throw new NotImplementedException ();}
+                       get { return eventID; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("Sequence numer of this event entry.")]
                public int Index {
-                       get {throw new NotImplementedException ();}
+                       get { return index; }
                }
 
-               [MonoTODO]
+#if NET_2_0
+               [ComVisible (false)]
+               public long InstanceId {
+                       get { return instanceId; }
+               }
+#endif
+
                [MonitoringDescription ("The Computer on which this event entry occured.")]
                public string MachineName {
-                       get {throw new NotImplementedException ();}
+                       get { return machineName; }
                }
 
-               [MonoTODO]
-               #if (NET_1_0)
-                       [Editor ("System.ComponentModel.Design.BinaryEditor, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
-               #endif
-               #if (NET_1_1)
-                       [Editor ("System.ComponentModel.Design.BinaryEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
-               #endif
+               [Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
                [MonitoringDescription ("The message of this event entry.")]
                public string Message {
-                       get {throw new NotImplementedException ();}
+                       get { return message; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("Application strings for this event entry.")]
                public string[] ReplacementStrings {
-                       get {throw new NotImplementedException ();}
+                       get { return replacementStrings; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("The source application of this event entry.")]
                public string Source {
-                       get {throw new NotImplementedException ();}
+                       get { return source; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("Generation time of this event entry.")]
                public DateTime TimeGenerated {
-                       get {throw new NotImplementedException ();}
+                       get { return timeGenerated; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("The time at which this event entry was written to the logfile.")]
                public DateTime TimeWritten {
-                       get {throw new NotImplementedException ();}
+                       get { return timeWritten; }
                }
 
-               [MonoTODO]
                [MonitoringDescription ("The name of a user associated with this event entry.")]
                public string UserName {
-                       get {throw new NotImplementedException ();}
+                       get { return userName; }
                }
 
-               [MonoTODO]
-               public bool Equals(EventLogEntry otherEntry)
+               public bool Equals (EventLogEntry otherEntry)
                {
-                       throw new NotImplementedException ();
-               }
-
-               [MonoTODO]
-               void ISerializable.GetObjectData(SerializationInfo info, 
+                       if (otherEntry == this)
+                               return true;
+
+                       return (
+                               (otherEntry.Category == category) &&
+                               (otherEntry.CategoryNumber == categoryNumber) &&
+                               (otherEntry.Data.Equals (data)) &&
+                               (otherEntry.EntryType == entryType) &&
+                               (otherEntry.EventID == eventID) &&
+                               (otherEntry.Index == index) &&
+                               (otherEntry.MachineName == machineName) &&
+                               (otherEntry.Message == message) &&
+                               (otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
+                               (otherEntry.Source == source) &&
+                               (otherEntry.TimeGenerated.Equals (timeGenerated)) &&
+                               (otherEntry.TimeWritten.Equals (timeWritten)) &&
+                               (otherEntry.UserName == userName)
+                               );
+               }
+
+               [MonoTODO ("Needs serialization support")]
+               void ISerializable.GetObjectData (SerializationInfo info, 
                        StreamingContext context)
                {
                        throw new NotImplementedException ();