Author: atsushi
Date: 2006-08-14 02:00:46 -0400 (Mon, 14 Aug 2006)
New Revision: 63704

Removed:
   trunk/mcs/class/System/System.Diagnostics/UnixEventLog.cs
   trunk/mcs/class/System/System.Diagnostics/Win32EventLog.cs
Modified:
   trunk/mcs/class/System/ChangeLog
   trunk/mcs/class/System/System.Diagnostics/ChangeLog
   trunk/mcs/class/System/System.Diagnostics/EventLog.cs
   trunk/mcs/class/System/System.Diagnostics/EventLogEntry.cs
   trunk/mcs/class/System/System.Diagnostics/EventLogEntryCollection.cs
   trunk/mcs/class/System/System.Diagnostics/EventLogImpl.cs
   trunk/mcs/class/System/System.Diagnostics/EventSourceCreationData.cs
   trunk/mcs/class/System/System.dll.sources
Log:
2006-08-14  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * UnixEventLog.cs, EventLogEntry.cs, EventSourceCreationData.cs,
          EventLogImpl.cs, Win32EventLog.cs, EventLogEntryCollection.cs,
          EventLog.cs:
          Reverted previous two changes that does not work at all.

        * System.dll.sources : reverted all recent changes on EventLogs.
          It does not work at all.



Modified: trunk/mcs/class/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/ChangeLog    2006-08-14 05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/ChangeLog    2006-08-14 06:00:46 UTC (rev 63704)
@@ -1,3 +1,8 @@
+2006-08-11  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * System.dll.sources : reverted all recent changes on EventLogs.
+         It does not work at all.
+
 2006-08-11  Gert Driesen  <[EMAIL PROTECTED]>
 
        * System.dll.sources: Added UnixEventLog.cs and Win32EventLog.cs.

Modified: trunk/mcs/class/System/System.Diagnostics/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/ChangeLog 2006-08-14 05:32:31 UTC 
(rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/ChangeLog 2006-08-14 06:00:46 UTC 
(rev 63704)
@@ -1,3 +1,10 @@
+2006-08-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * UnixEventLog.cs, EventLogEntry.cs, EventSourceCreationData.cs,
+         EventLogImpl.cs, Win32EventLog.cs, EventLogEntryCollection.cs,
+         EventLog.cs:
+         Reverted previous two changes that does not work at all.
+
 2006-08-11  Gert Driesen  <[EMAIL PROTECTED]>
 
        * EventLog.cs: For now, Use null implementation.

Modified: trunk/mcs/class/System/System.Diagnostics/EventLog.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/EventLog.cs       2006-08-14 
05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/EventLog.cs       2006-08-14 
06:00:46 UTC (rev 63704)
@@ -32,14 +32,9 @@
 
 using System;
 using System.Diagnostics;
-using System.Collections;
 using System.ComponentModel;
 using System.ComponentModel.Design;
-using System.Globalization;
-using System.IO;
 
-using Microsoft.Win32;
-
 namespace System.Diagnostics 
 {
        [DefaultEvent ("EntryWritten")]
@@ -47,6 +42,7 @@
        [Designer 
("Microsoft.VisualStudio.Install.EventLogInstallableComponentDesigner, " + 
Consts.AssemblyMicrosoft_VisualStudio)]
        public class EventLog : Component, ISupportInitialize 
        {
+
                private string source;
                private string logName;
                private string machineName;
@@ -56,7 +52,7 @@
                private EventLogImpl Impl;
 
                public EventLog()
-                       : this (string.Empty)
+                       : this ("")
                {
                }
 
@@ -65,34 +61,19 @@
                {
                }
 
-               public EventLog(string logName, string machineName)
-                       : this (logName, machineName, string.Empty)
+               public EventLog(string logName, string machineName) 
+                       : this (logName, machineName, "")
                {
                }
 
                public EventLog(string logName, string machineName, string 
source)
                {
-                       if (logName == null) {
-                               throw new ArgumentNullException ("logName");
-                       }
-                       if (machineName == null || machineName.Length == 0)
-                               throw new ArgumentException (string.Format (
-                                       CultureInfo.InvariantCulture, "Invalid 
value '{0}' for"
-                                       + " parameter 'machineName'.", 
machineName));
-
                        this.source = source;
                        this.machineName = machineName;
                        this.logName = logName;
 
-                       Impl = new NullEventLog (this);
-                       /*
-                       if (Win32EventLogEnabled) {
-                               Impl = new Win32EventLog (this);
-                       } else {
-                               Impl = new UnixEventLog (this);
-                       }
-                       */
-                       Impl.EntryWritten += new EntryWrittenEventHandler 
(EntryWrittenHandler);
+                       this.Impl = new EventLogImpl (this);
+                       EventLogImpl.EntryWritten += new 
EntryWrittenEventHandler (EntryWrittenHandler);
                }
 
                private void EntryWrittenHandler (object sender, 
EntryWrittenEventArgs e)
@@ -111,23 +92,15 @@
                [Browsable (false), DesignerSerializationVisibility 
(DesignerSerializationVisibility.Hidden)]
                [MonitoringDescription ("The entries in the log.")]
                public EventLogEntryCollection Entries {
-                       get {return new EventLogEntryCollection(Impl);}
+                       get {return Impl.Entries;}
                }
 
                [ReadOnly (true), DefaultValue (""), RecommendedAsConfigurable 
(true)]
                [TypeConverter ("System.Diagnostics.Design.LogConverter, " + 
Consts.AssemblySystem_Design)]
                [MonitoringDescription ("Name of the log that is read and 
written.")]
                public string Log {
-                       get {
-                               if (source != null && source.Length > 0)
-                                       return GetLogName ();
-                               return logName;
-                       }
-                       set {
-                               if (value == null)
-                                       throw new ArgumentNullException 
("value");
-                               logName = value;
-                       }
+                       get {return logName;}
+                       set {logName = value;}
                }
 
                [Browsable (false)]
@@ -146,8 +119,8 @@
                [TypeConverter 
("System.Diagnostics.Design.StringValueConverter, " + 
Consts.AssemblySystem_Design)]
                [MonitoringDescription ("The application name that writes the 
log.")]
                public string Source {
-                       get { return source; }
-                       set { source = (value == null) ? string.Empty : value; }
+                       get {return source;}
+                       set {source = value;}
                }
 
                [Browsable (false), DefaultValue (null)]
@@ -181,129 +154,17 @@
                        string logName, 
                        string machineName)
                {
-                       CreateEventSource (new EventSourceCreationData (source, 
logName,
-                               machineName));
+                       EventLogImpl.CreateEventSource (source, logName, 
machineName);
                }
 
-#if NET_2_0
-               [MonoTODO ("Support remote machine")]
-               public
-#else
-               private
-#endif
-               static void CreateEventSource (EventSourceCreationData 
sourceData)
-               {
-                       if (sourceData.Source == null || 
sourceData.Source.Length == 0) {
-                               throw new ArgumentException ("Source is not 
set");
-                       }
-                       if (sourceData.LogName == null || 
sourceData.LogName.Length == 0) {
-                               throw new ArgumentException ("LogName is not 
set");
-                       }
-
-                       if (SourceExists (sourceData.Source, 
sourceData.MachineName)) {
-                               throw new ArgumentException (string.Format 
(CultureInfo.InvariantCulture,
-                                       "Source '{0}' already exists on 
'{1}'.", sourceData.Source,
-                                       sourceData.MachineName));
-                       }
-
-                       using (RegistryKey eventLogKey = GetEventLogKey 
(sourceData.MachineName, true)) {
-                               if (eventLogKey == null)
-                                       throw new InvalidOperationException 
("EventLog registry key is missing.");
-
-                               bool logKeyCreated = false;
-                               RegistryKey logKey = null;
-                               try {
-                                       logKey = eventLogKey.OpenSubKey 
(sourceData.LogName, true);
-                                       if (logKey == null) {
-                                               logKey = 
eventLogKey.CreateSubKey (sourceData.LogName);
-                                               logKey.SetValue ("Sources", new 
string[] { sourceData.LogName,
-                                                       sourceData.Source });
-                                               UpdateLogRegistry (logKey);
-
-                                               using (RegistryKey sourceKey = 
logKey.CreateSubKey (sourceData.LogName)) {
-                                                       UpdateSourceRegistry 
(sourceKey, sourceData);
-                                               }
-
-                                               logKeyCreated = true;
-                                       }
-
-                                       if (sourceData.LogName != 
sourceData.Source) {
-                                               if (!logKeyCreated) {
-                                                       string[] sources = 
(string[]) logKey.GetValue ("Sources");
-                                                       if (sources == null) {
-                                                               logKey.SetValue 
("Sources", new string[] { sourceData.LogName,
-                                                                       
sourceData.Source });
-                                                       } else {
-                                                               bool found = 
false;
-                                                               for (int i = 0; 
i < sources.Length; i++) {
-                                                                       if 
(sources[i] == sourceData.Source) {
-                                                                               
found = true;
-                                                                               
break;
-                                                                       }
-                                                               }
-                                                               if (!found) {
-                                                                       
string[] newSources = new string[sources.Length + 1];
-                                                                       
Array.Copy (sources, 0, newSources, 0, sources.Length);
-                                                                       
newSources[sources.Length] = sourceData.Source;
-                                                                       
logKey.SetValue ("Sources", newSources);
-                                                               }
-                                                       }
-                                               }
-                                               using (RegistryKey sourceKey = 
logKey.CreateSubKey (sourceData.Source)) {
-                                                       UpdateSourceRegistry 
(sourceKey, sourceData);
-                                               }
-                                       }
-                               } finally {
-                                       if (logKey != null)
-                                               logKey.Close ();
-                               }
-                       }
-               }
-
                public static void Delete(string logName)
                {
                        Delete (logName, ".");
                }
 
-               [MonoTODO ("Support remote machine")]
-               public static void Delete (string logName, string machineName)
+               public static void Delete(string logName, string machineName)
                {
-                       if (machineName == null || machineName.Length == 0)
-                               throw new ArgumentException ("Invalid format 
for argument"
-                                       + " machineName.");
-
-                       if (logName == null || logName.Length == 0)
-                               throw new ArgumentException ("Log to delete was 
not specified.");
-
-                       using (RegistryKey eventLogKey = GetEventLogKey 
(machineName, true)) {
-                               if (eventLogKey == null)
-                                       throw new InvalidOperationException 
("The event log key does not exist.");
-
-                               using (RegistryKey logKey = 
eventLogKey.OpenSubKey (logName, false)) {
-                                       if (logKey == null)
-                                               throw new 
InvalidOperationException (string.Format (
-                                                       
CultureInfo.InvariantCulture, "Event Log '{0}'"
-                                                       + " does not exist on 
computer '{1}'.", logName,
-                                                       machineName));
-
-                                       // remove all eventlog entries for 
specified log
-                                       using (EventLog eventLog = new EventLog 
(logName, machineName)) {
-                                               eventLog.Clear ();
-                                       }
-
-                                       // remove file holding event log entries
-                                       string file = (string) logKey.GetValue 
("File");
-                                       if (file != null) {
-                                               try {
-                                                       File.Delete (file);
-                                               } catch (Exception) {
-                                                       // .NET seems to ignore 
failures here
-                                               }
-                                       }
-                               }
-
-                               eventLogKey.DeleteSubKeyTree (logName);
-                       }
+                       EventLogImpl.Delete (logName, machineName);
                }
 
                public static void DeleteEventSource(string source)
@@ -311,37 +172,13 @@
                        DeleteEventSource (source, ".");
                }
 
-               [MonoTODO ("Support remote machine")]
-               public static void DeleteEventSource (string source, string 
machineName)
+               public static void DeleteEventSource(string source, 
+                       string machineName)
                {
-                       if (machineName == null || machineName.Length == 0)
-                               throw new ArgumentException (string.Format (
-                                       CultureInfo.InvariantCulture, "Invalid 
value '{0}' for"
-                                       + " parameter 'machineName'.", 
machineName));
-
-                       using (RegistryKey logKey = FindLogKeyBySource (source, 
machineName, true)) {
-                               if (logKey == null) {
-                                       throw new ArgumentException 
(string.Format (
-                                               CultureInfo.InvariantCulture, 
"The source '{0}' is not"
-                                               + " registered on computer 
'{1}'.", source, machineName));
-                               }
-
-                               logKey.DeleteSubKeyTree (source);
-
-                               string[] sources = (string[]) logKey.GetValue 
("Sources");
-                               if (sources != null) {
-                                       ArrayList temp = new ArrayList ();
-                                       for (int i = 0; i < sources.Length; i++)
-                                               if (sources[i] != source)
-                                                       temp.Add (sources[i]);
-                                       string[] newSources = new 
string[temp.Count];
-                                       temp.CopyTo (newSources, 0);
-                                       logKey.SetValue ("Sources", newSources);
-                               }
-                       }
+                       EventLogImpl.DeleteEventSource (source, machineName);
                }
 
-               protected override void Dispose (bool disposing)
+               protected override void Dispose(bool disposing)
                {
                        Impl.Dispose (disposing);
                }
@@ -356,45 +193,25 @@
                        return Exists (logName, ".");
                }
 
-               [MonoTODO ("Support remote machine")]
-               public static bool Exists (string logName, string machineName)
+               public static bool Exists(string logName, string machineName)
                {
-                       using (RegistryKey logKey = FindLogKeyByName (logName, 
machineName, false)) {
-                               return (logKey != null);
-                       }
+                       return EventLogImpl.Exists (logName, machineName);
                }
 
-               public static EventLog[] GetEventLogs ()
+               public static EventLog[] GetEventLogs()
                {
                        return GetEventLogs (".");
                }
 
-               [MonoTODO ("Support remote machine")]
-               public static EventLog[] GetEventLogs (string machineName)
+               public static EventLog[] GetEventLogs(string machineName)
                {
-                       using (RegistryKey eventLogKey = GetEventLogKey 
(machineName, false)) {
-                               if (eventLogKey == null) {
-                                       throw new InvalidOperationException 
("TODO");
-                               }
-                               string[] logNames = eventLogKey.GetSubKeyNames 
();
-                               EventLog[] eventLogs = new 
EventLog[logNames.Length];
-                               for (int i = 0; i < logNames.Length; i++) {
-                                       EventLog eventLog = new EventLog 
(logNames[i], machineName);
-                                       eventLogs[i] = eventLog;
-                               }
-                               return eventLogs;
-                       }
+                       return EventLogImpl.GetEventLogs (machineName);
                }
 
-               [MonoTODO ("Support remote machine")]
-               public static string LogNameFromSourceName (string source, 
string machineName)
+               public static string LogNameFromSourceName(string source, 
+                       string machineName)
                {
-                       using (RegistryKey logKey = FindLogKeyBySource (source, 
machineName, false)) {
-                               if (logKey == null)
-                                       return string.Empty;
-
-                               return GetLogName (logKey);
-                       }
+                       return EventLogImpl.LogNameFromSourceName (source, 
machineName);
                }
 
                public static bool SourceExists(string source)
@@ -402,20 +219,9 @@
                        return SourceExists (source, ".");
                }
 
-               [MonoTODO ("Support remote machines")]
-               public static bool SourceExists (string source, string 
machineName)
+               public static bool SourceExists(string source, string 
machineName)
                {
-                       if (machineName == null || machineName.Length == 0)
-                               throw new ArgumentException (string.Format (
-                                       CultureInfo.InvariantCulture, "Invalid 
value '{0}' for"
-                                       + " parameter 'machineName'.", 
machineName));
-
-                       RegistryKey logKey = FindLogKeyBySource (source, 
machineName, false);
-                       if (logKey != null) {
-                               logKey.Close ();
-                               return true;
-                       }
-                       return false;
+                       return EventLogImpl.SourceExists (source, machineName);
                }
 
                public void WriteEntry(string message)
@@ -438,18 +244,6 @@
                        int eventID,
                        short category)
                {
-                       if (Source.Length == 0) {
-                               throw new ArgumentException ("Source property 
was not set"
-                                       + "before writing to the event log.");
-                       }
-
-                       if (!SourceExists (Source, MachineName)) {
-                               if (Log == null || Log.Length == 0) {
-                                       Log = "Application";
-                               }
-                               CreateEventSource (Source, Log, MachineName);
-                       }
-
                        WriteEntry (message, type, eventID, category, null);
                }
 
@@ -487,10 +281,7 @@
                        EventLogEntryType type, int eventID, short category, 
                        byte[] rawData)
                {
-                       using (EventLog eventLog = new EventLog ()) {
-                               eventLog.Source = source;
-                               eventLog.WriteEntry (message, type, eventID, 
category, rawData);
-                       }
+                       EventLogImpl.WriteEntry (source, message, type, 
eventID, category, rawData);
                }
 
                internal void OnEntryWritten (EventLogEntry newEntry)
@@ -501,116 +292,6 @@
 
                [MonitoringDescription ("Raised for each EventLog entry 
written.")]
                public event EntryWrittenEventHandler EntryWritten;
-
-               internal string GetLogName ()
-               {
-                       if (logName != null && logName.Length > 0)
-                               return logName;
-
-                       // if no log name has been set, then use source to 
determine name of log
-                       logName = LogNameFromSourceName (source, machineName);
-                       return logName;
-               }
-
-               private static bool Win32EventLogEnabled {
-                       get {
-                               return (Environment.OSVersion.Platform == 
PlatformID.Win32NT);
-                       }
-               }
-
-               private static void UpdateLogRegistry (RegistryKey logKey)
-               {
-                       if (!Win32EventLogEnabled)
-                               return;
-
-                       // TODO: write other Log values:
-                       // - MaxSize
-                       // - Retention
-                       // - AutoBackupLogFiles
-
-                       if (logKey.GetValue ("File") == null) {
-                               string logName = GetLogName (logKey);
-                               string file;
-                               if (logName.Length > 8) {
-                                       file = logName.Substring (0, 8) + 
".evt";
-                               } else {
-                                       file = logName + ".evt";
-                               }
-                               string configPath = Path.Combine 
(Environment.GetFolderPath (
-                                       Environment.SpecialFolder.System), 
"config");
-                               logKey.SetValue ("File", Path.Combine 
(configPath, file));
-                       }
-
-               }
-
-               private static void UpdateSourceRegistry (RegistryKey 
sourceKey, EventSourceCreationData data)
-               {
-                       if (data.CategoryCount > 0)
-                               sourceKey.SetValue ("CategoryCount", 
data.CategoryCount);
-
-                       if (data.CategoryResourceFile != null && 
data.CategoryResourceFile.Length > 0)
-                               sourceKey.SetValue ("CategoryMessageFile", 
data.CategoryResourceFile);
-
-                       if (data.MessageResourceFile != null && 
data.MessageResourceFile.Length > 0)
-                               sourceKey.SetValue ("EventMessageFile", 
data.MessageResourceFile);
-
-                       if (data.ParameterResourceFile != null && 
data.ParameterResourceFile.Length > 0)
-                               sourceKey.SetValue ("ParameterMessageFile", 
data.ParameterResourceFile);
-               }
-
-               private static string GetLogName (RegistryKey logKey) {
-                       string logName = logKey.Name;
-                       return logName.Substring (logName.LastIndexOf ("\\") + 
1);
-               }
-
-               [MonoTODO ("Support remote machines")]
-               private static RegistryKey GetEventLogKey (string machineName, 
bool writable)
-               {
-                       return Registry.LocalMachine.OpenSubKey 
(@"SYSTEM\CurrentControlSet\Services\EventLog", writable);
-               }
-
-               private static RegistryKey FindLogKeyByName (string logName, 
string machineName, bool writable)
-               {
-                       using (RegistryKey eventLogKey = GetEventLogKey 
(machineName, writable)) {
-                               if (eventLogKey == null) {
-                                       return null;
-                               }
-
-                               return eventLogKey.OpenSubKey (logName, 
writable);
-                       }
-               }
-
-               private static RegistryKey FindLogKeyBySource (string source, 
string machineName, bool writable)
-               {
-                       if (source == null || source.Length == 0)
-                               return null;
-
-                       RegistryKey eventLogKey = null;
-                       try {
-                               eventLogKey = GetEventLogKey (machineName, 
writable);
-                               if (eventLogKey == null)
-                                       return null;
-
-                               string[] subKeys = eventLogKey.GetSubKeyNames 
();
-                               for (int i = 0; i < subKeys.Length; i++) {
-                                       RegistryKey sourceKey = null;
-                                       try {
-                                               RegistryKey logKey = 
eventLogKey.OpenSubKey (subKeys[i], writable);
-                                               if (logKey != null) {
-                                                       sourceKey = 
logKey.OpenSubKey (source, writable);
-                                                       if (sourceKey != null)
-                                                               return logKey;
-                                               }
-                                       } finally {
-                                               if (sourceKey != null)
-                                                       sourceKey.Close ();
-                                       }
-                               }
-                               return null;
-                       } finally {
-                               if (eventLogKey != null)
-                                       eventLogKey.Close ();
-                       }
-               }
        }
 }
+

Modified: trunk/mcs/class/System/System.Diagnostics/EventLogEntry.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/EventLogEntry.cs  2006-08-14 
05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/EventLogEntry.cs  2006-08-14 
06:00:46 UTC (rev 63704)
@@ -31,9 +31,6 @@
 //
 
 using System.ComponentModel;
-#if NET_2_0
-using System.Runtime.InteropServices;
-#endif
 using System.Runtime.Serialization;
 using System.Security.Permissions;
 
@@ -59,15 +56,12 @@
                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)
+                                       int eventID, string message, string 
source,
+                                       string userName, string machineName, 
EventLogEntryType entryType,
+                                       DateTime timeGenerated, DateTime 
timeWritten, byte[] data,
+                                       string[] replacementStrings)
                {
                        this.category = category;
                        this.categoryNumber = categoryNumber;
@@ -82,9 +76,6 @@
                        this.timeGenerated = timeGenerated;
                        this.timeWritten = timeWritten;
                        this.userName = userName;
-#if NET_2_0
-                       this.instanceId = instanceId;
-#endif
                }
 
                [MonoTODO]
@@ -107,14 +98,14 @@
                        get { return data; }
                }
 
+#if NET_2_0
+               [Obsolete ("Use InstanceId")]
+#endif
                [MonitoringDescription ("The type of this event entry.")]
                public EventLogEntryType EntryType {
                        get { return entryType; }
                }
 
-#if NET_2_0
-               [Obsolete ("Use InstanceId")]
-#endif
                [MonitoringDescription ("An ID number for this event entry.")]
                public int EventID {
                        get { return eventID; }
@@ -125,13 +116,6 @@
                        get { return index; }
                }
 
-#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 { return machineName; }

Modified: trunk/mcs/class/System/System.Diagnostics/EventLogEntryCollection.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/EventLogEntryCollection.cs        
2006-08-14 05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/EventLogEntryCollection.cs        
2006-08-14 06:00:46 UTC (rev 63704)
@@ -37,79 +37,42 @@
 
        public class EventLogEntryCollection : ICollection, IEnumerable {
 
-               readonly EventLogImpl _impl;
+               private ArrayList eventLogs = new ArrayList ();
 
-               internal EventLogEntryCollection(EventLogImpl impl)
+               internal EventLogEntryCollection()
                {
-                       _impl = impl;
                }
 
                public int Count {
-                       get { return _impl.EntryCount; }
+                       get {return eventLogs.Count;}
                }
 
                public virtual EventLogEntry this [int index] {
-                       get { return _impl[index]; }
+                       get {return (EventLogEntry) eventLogs[index];}
                }
 
                bool ICollection.IsSynchronized {
-                       get { return false; }
+                       get {return eventLogs.IsSynchronized;}
                }
 
                object ICollection.SyncRoot {
-                       get { return this; }
+                       get {return eventLogs.SyncRoot;}
                }
 
-               public void CopyTo (EventLogEntry[] eventLogEntries, int index)
+               public void CopyTo (EventLogEntry[] eventLogs, int index)
                {
-                       EventLogEntry[] entries = _impl.GetEntries ();
-                       Array.Copy (entries, 0, eventLogEntries, index, 
entries.Length);
+                       eventLogs.CopyTo (eventLogs, index);
                }
 
                public IEnumerator GetEnumerator ()
                {
-                       return new EventLogEntryEnumerator (_impl);
+                       return eventLogs.GetEnumerator ();
                }
 
                void ICollection.CopyTo (Array array, int index)
                {
-                       EventLogEntry[] entries = _impl.GetEntries ();
-                       Array.Copy (entries, 0, array, index, entries.Length);
+                       eventLogs.CopyTo (array, index);
                }
-
-               private class EventLogEntryEnumerator : IEnumerator
-               {
-                       internal EventLogEntryEnumerator (EventLogImpl impl)
-                       {
-                               _impl = impl;
-                       }
-
-                       object IEnumerator.Current {
-                               get { return Current; }
-                       }
-
-                       public EventLogEntry Current
-                       {
-                               get { return _currentEntry; }
-                       }
-
-                       public bool MoveNext ()
-                       {
-                               _currentIndex++;
-                               _currentEntry = _impl[_currentIndex];
-                               return _currentEntry != null;
-                       }
-
-                       public void Reset ()
-                       {
-                               _currentIndex = - 1;
-                               _currentEntry = null;
-                       }
-
-                       readonly EventLogImpl _impl;
-                       int _currentIndex = -1;
-                       EventLogEntry _currentEntry;
-               }
+       }
 }
-}
 

Modified: trunk/mcs/class/System/System.Diagnostics/EventLogImpl.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/EventLogImpl.cs   2006-08-14 
05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/EventLogImpl.cs   2006-08-14 
06:00:46 UTC (rev 63704)
@@ -6,6 +6,7 @@
 //
 // (C) 2003 Andreas Nahr
 //
+
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -28,172 +29,92 @@
 //
 
 using System;
+using System.Diagnostics;
 using System.ComponentModel;
 using System.ComponentModel.Design;
-using System.Diagnostics;
-using System.Globalization;
 
-using Microsoft.Win32;
-
 namespace System.Diagnostics
 {
-       internal abstract class EventLogImpl
-       {
-               readonly EventLog _coreEventLog;
 
-               protected EventLogImpl (EventLog coreEventLog)
-               {
-                       _coreEventLog = coreEventLog;
-               }
+// FIXME set a symbol for every implementation and include the implementation
+#if (EVENTLOG_WIN32)
 
-               public event EntryWrittenEventHandler EntryWritten;
+       // TODO implement the EventLog for Win32 platforms
 
-               protected EventLog CoreEventLog {
-                       get { return _coreEventLog; }
-               }
+#elif (EVENTLOG_GENERIC)
 
-               public int EntryCount {
-                       get {
-                               if (_coreEventLog.Log == null || 
_coreEventLog.Log.Length == 0) {
-                                       throw new ArgumentException ("Log 
property is not set.");
-                               }
+       // TODO implement a generic (XML - based?) Eventlog for non - Win32 
platforms
 
-                               if (!EventLog.Exists (_coreEventLog.Log, 
_coreEventLog.MachineName)) {
-                                       throw new InvalidOperationException 
(string.Format (
-                                               CultureInfo.InvariantCulture, 
"The event log '{0}' on "
-                                               + " computer '{1}' does not 
exist.", _coreEventLog.Log,
-                                               _coreEventLog.MachineName));
-                               }
-
-                               return GetEntryCount ();
-                       }
+#else
+       // Empty implementation that does not need any specific platform
+       // but should be enough to get applications to run that WRITE to 
eventlog
+       internal class EventLogImpl
+       {
+               public EventLogImpl (EventLog coreEventLog)
+               {
                }
 
-               public EventLogEntry this[int index] {
-                       get {
-                               if (_coreEventLog.Log == null || 
_coreEventLog.Log.Length == 0) {
-                                       throw new ArgumentException ("Log 
property is not set.");
-                               }
+               public static event EntryWrittenEventHandler EntryWritten;
 
-                               if (!EventLog.Exists (_coreEventLog.Log, 
_coreEventLog.MachineName)) {
-                                       throw new InvalidOperationException 
(string.Format (
-                                               CultureInfo.InvariantCulture, 
"The event log '{0}' on "
-                                               + " computer '{1}' does not 
exist.", _coreEventLog.Log,
-                                               _coreEventLog.MachineName));
-                               }
-
-                               if (index < 0 || index >= EntryCount)
-                                       throw new ArgumentException ("Index out 
of range");
-
-                               return GetEntry (index);
-                       }
+               public EventLogEntryCollection Entries {
+                       get {return new EventLogEntryCollection ();}
                }
 
                public string LogDisplayName {
-                       get {
-#if NET_2_0
-                               // to-do perform valid character checks
-                               if (_coreEventLog.Log != null && 
_coreEventLog.Log.Length == 0) {
-                                       throw new InvalidOperationException 
("Event log names must"
-                                               + " consist of printable 
characters and cannot contain"
-                                               + " \\, *, ?, or spaces.");
-                               }
-#endif
-                               if (_coreEventLog.Log != null) {
-                                       if (!EventLog.Exists 
(_coreEventLog.Log, _coreEventLog.MachineName)) {
-                                               throw new 
InvalidOperationException (string.Format (
-                                                       
CultureInfo.InvariantCulture, "Cannot find Log {0}"
-                                                       + " on computer {1}.", 
_coreEventLog.Log,
-                                                       
_coreEventLog.MachineName));
-                                       }
-                               }
-
-                               return GetLogDisplayName ();
-                       }
+                       get {return "";}
                }
 
-               public abstract void BeginInit ();
+               public void BeginInit () {}
 
-               public abstract void Clear ();
+               public void Clear () {}
 
-               public abstract void Close ();
+               public void Close () {}
 
-               public abstract void Dispose (bool disposing);
+               public static void CreateEventSource (string source, string 
logName, string machineName) {}
 
-               public abstract void EndInit ();
+               public static void Delete (string logName, string machineName) 
{}
 
-               public abstract EventLogEntry[] GetEntries ();
+               public static void DeleteEventSource (string source, string 
machineName) {}
 
-               protected abstract int GetEntryCount ();
+               public void Dispose (bool disposing) {}
 
-               protected abstract EventLogEntry GetEntry (int index);
+               public void EndInit () {}
 
-               protected abstract string GetLogDisplayName ();
-
-               protected abstract void WriteEventLogEntry (EventLogEntry 
entry);
-
-               public void WriteEntry (string message, EventLogEntryType type, 
int eventID, short category, byte[] rawData)
+               public static bool Exists (string logName, string machineName)
                {
-                       EventLogEntry entry = new EventLogEntry (string.Empty, 
category, 0, eventID,
-                               _coreEventLog.Source, message, string.Empty, 
_coreEventLog.MachineName,
-                               type, DateTime.Now, DateTime.Now, rawData, new 
string [] { message }, eventID);
-                       WriteEventLogEntry (entry);
-                       if (EntryWritten != null)
-                               EntryWritten (null, new EntryWrittenEventArgs 
(entry));
+                       return false;
                }
-       }
 
-       // Empty implementation that does not need any specific platform
-       // but should be enough to get applications to run that WRITE to 
eventlog
-       internal class NullEventLog : EventLogImpl
-       {
-               public NullEventLog (EventLog coreEventLog)
-                       : base (coreEventLog)
+               public static EventLog[] GetEventLogs (string machineName)
                {
+                       return new EventLog[0];
                }
 
-               public override void BeginInit ()
+               public static string LogNameFromSourceName (string source, 
string machineName)
                {
+                       return String.Empty;
                }
 
-               public override void Clear ()
+               public static bool SourceExists (string source, string 
machineName)
                {
+                       return false;
                }
 
-               public override void Close ()
+               public void WriteEntry (string message, EventLogEntryType type, 
int eventID, short category, byte[] rawData)
                {
+                       WriteEntry ("", message, type, eventID, category, 
rawData);
                }
 
-               public override void Dispose (bool disposing)
+               public static void WriteEntry (string source, string message, 
EventLogEntryType type, int eventID, short category, byte[] rawData)
                {
+                       EventLogEntry Entry;
+                       Entry = new EventLogEntry ("", category, 0, eventID, 
message, source, 
+                               "", "", type, DateTime.Now, DateTime.Now, 
rawData, null);
+                       if (EntryWritten != null)
+                               EntryWritten (null, new EntryWrittenEventArgs 
(Entry));
                }
+       }
 
-               public override void EndInit ()
-               {
-               }
+#endif
 
-               public override EventLogEntry[] GetEntries ()
-               {
-                       return new EventLogEntry[0];
-               }
-
-               protected override int GetEntryCount ()
-               {
-                       return 0;
-               }
-
-               protected override EventLogEntry GetEntry (int index)
-               {
-                       return null;
-               }
-
-               protected override string GetLogDisplayName ()
-               {
-                       return CoreEventLog.Log;
-               }
-
-               protected override void WriteEventLogEntry (EventLogEntry entry)
-               {
-               }
-       }
 }

Modified: trunk/mcs/class/System/System.Diagnostics/EventSourceCreationData.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/EventSourceCreationData.cs        
2006-08-14 05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/EventSourceCreationData.cs        
2006-08-14 06:00:46 UTC (rev 63704)
@@ -1,10 +1,10 @@
 //
 // System.Diagnostics.EventSourceCreationData
 //
-// Author:
-//     Gert Driesen <[EMAIL PROTECTED]>
+// Authors:
+//     Gert Driesen ([EMAIL PROTECTED])
 //
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// (C) 2006 Novell
 //
 //
 // Permission is hereby granted, free of charge, to any person obtaining
@@ -52,11 +52,7 @@
                internal EventSourceCreationData (string source, string 
logName, string machineName)
                {
                        _source = source;
-                       if (logName == null || logName.Length == 0) {
-                               _logName = "Application";
-                       } else {
-                               _logName = logName;
-                       }
+                       _logName = logName;
                        _machineName = machineName;
                }
 

Deleted: trunk/mcs/class/System/System.Diagnostics/UnixEventLog.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/UnixEventLog.cs   2006-08-14 
05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/UnixEventLog.cs   2006-08-14 
06:00:46 UTC (rev 63704)
@@ -1,219 +0,0 @@
-//
-// System.Diagnostics.UnixEventLog.cs
-//
-// Author:
-//     Gert Driesen <[EMAIL PROTECTED]>
-//     Atsushi Enum <[EMAIL PROTECTED]>
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-//
-// 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;
-using System.Collections;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-
-namespace System.Diagnostics
-{
-       internal class UnixEventLog : EventLogImpl
-       {
-               const string DateFormat = "yyyyMMddHHmmssfff";
-               static readonly object lockObject = new object ();
-
-               public UnixEventLog (EventLog coreEventLog) : base 
(coreEventLog)
-               {
-               }
-
-               public override void BeginInit () {
-               }
-
-               public override void Clear ()
-               {
-                       if (!Directory.Exists (FileStore))
-                               return;
-
-                       foreach (string file in Directory.GetFiles (FileStore, 
"*.log"))
-                               File.Delete (file);
-                       Directory.Delete (FileStore);
-               }
-
-               public override void Close ()
-               {
-                       // we don't hold any unmanaged resources
-               }
-
-               public override void Dispose (bool disposing)
-               {
-                       Close ();
-               }
-
-               public override void EndInit () { }
-
-               public override EventLogEntry[] GetEntries ()
-               {
-                       if (!Directory.Exists (FileStore))
-                               return new EventLogEntry [0];
-
-                       int entryCount = GetEntryCount ();
-                       EventLogEntry [] entries = new EventLogEntry 
[entryCount];
-                       for (int i = 0; i < entryCount; i++) {
-                               entries [i] = GetEntry (i);
-                       }
-                       return entries;
-               }
-
-               protected override int GetEntryCount ()
-               {
-                       if (!Directory.Exists (FileStore))
-                               return 0;
-
-                       string[] logFiles = Directory.GetFiles (FileStore, 
"*.log");
-                       return logFiles.Length;
-               }
-
-               protected override EventLogEntry GetEntry (int index)
-               {
-                       // our file names are one-based
-                       string file = Path.Combine (FileStore, (index + 
1).ToString (
-                               CultureInfo.InvariantCulture) + ".log");
-
-                       using (TextReader tr = File.OpenText (file)) {
-                               int eventIndex = int.Parse 
(Path.GetFileNameWithoutExtension (file),
-                                       CultureInfo.InvariantCulture);
-                               int id = int.Parse (tr.ReadLine ().Substring 
(9));
-                               long instanceId = long.Parse (tr.ReadLine 
().Substring (12),
-                                       CultureInfo.InvariantCulture);
-                               EventLogEntryType type = (EventLogEntryType)
-                                       Enum.Parse (typeof (EventLogEntryType), 
tr.ReadLine ().Substring (11));
-                               string source = tr.ReadLine ().Substring (8);
-                               string category = tr.ReadLine ().Substring (10);
-                               short categoryNumber = short.Parse(category, 
CultureInfo.InvariantCulture);
-                               string categoryName = "(" + category + ")";
-                               DateTime date = DateTime.ParseExact 
(tr.ReadLine ().Substring (15),
-                                       DateFormat, 
CultureInfo.InvariantCulture);
-                               int size = int.Parse (tr.ReadLine ().Substring 
(15));
-                               char [] buf = new char [size];
-                               tr.Read (buf, 0, size);
-                               ArrayList replacementTemp = new ArrayList ();
-                               StringBuilder sb = new StringBuilder ();
-                               for (int i = 0; i < buf.Length; i++) {
-                                       char c = buf[i];
-                                       if (c == '\0') {
-                                               replacementTemp.Add 
(sb.ToString ());
-                                               sb.Length = 0;
-                                       } else {
-                                               sb.Append (c);
-                                       }
-                               }
-                               if (sb.Length > 0) {
-                                       replacementTemp.Add (sb.ToString ());
-                               }
-                               string [] replacementStrings = new string 
[replacementTemp.Count];
-                               replacementTemp.CopyTo (replacementStrings, 0);
-                               DateTime timeWritten = File.GetLastWriteTime 
(file);
-
-                               byte [] bin = Convert.FromBase64String 
(tr.ReadToEnd ());
-                               return new EventLogEntry (categoryName, 
categoryNumber, eventIndex,
-                                       id, source, new string(buf), null, 
Environment.MachineName, 
-                                       type, date, timeWritten, bin, 
replacementStrings, instanceId);
-                       }
-               }
-
-               [MonoTODO]
-               protected override string GetLogDisplayName ()
-               {
-                       return CoreEventLog.Log;
-               }
-
-               protected override void WriteEventLogEntry (EventLogEntry entry)
-               {
-                       if (!Directory.Exists (FileStore))
-                               Directory.CreateDirectory (FileStore);
-
-                       lock (lockObject) {
-                               int index = GetNewIndex ();
-                               string logPath = Path.Combine (FileStore, 
index.ToString (CultureInfo.InvariantCulture) + ".log");
-                               try {
-                                       using (TextWriter w = File.CreateText 
(logPath)) {
-                                               w.WriteLine ("EventID: {0}", 
entry.EventID);
-#if NET_2_0
-                                               w.WriteLine ("InstanceID: {0}", 
entry.InstanceId);
-#else
-                                               w.WriteLine ("InstanceID: {0}", 
entry.EventID);
-#endif
-                                               w.WriteLine ("EntryType: {0}", 
entry.EntryType);
-                                               w.WriteLine ("Source: {0}", 
entry.Source);
-                                               w.WriteLine ("Category: {0}", 
entry.CategoryNumber.ToString (
-                                                       
CultureInfo.InvariantCulture));
-                                               w.WriteLine ("TimeGenerated: 
{0}", entry.TimeGenerated.ToString (
-                                                       DateFormat, 
CultureInfo.InvariantCulture));
-                                               StringBuilder sb = new 
StringBuilder ();
-                                               if (entry.ReplacementStrings != 
null) {
-                                                       for (int i = 0; i < 
entry.ReplacementStrings.Length; i++) {
-                                                               if (i > 0)
-                                                                       
sb.Append ('\0');
-                                                               string 
replacement = entry.ReplacementStrings[i];
-                                                               sb.Append 
(replacement);
-                                                       }
-                                               }
-                                               w.WriteLine ("MessageLength: 
{0}", sb.Length);
-                                               w.Write (sb.ToString ());
-                                               if (entry.Data != null)
-                                                       w.Write 
(Convert.ToBase64String (entry.Data));
-                                       }
-                               } catch (IOException) {
-                                       File.Delete (logPath);
-                               }
-                       }
-               }
-
-               private string FileStore {
-                       get {
-                               string eventLogRoot = Path.Combine 
(Environment.GetFolderPath (
-                                       Environment.SpecialFolder.Personal), 
".mono/eventlog");
-                               return Path.Combine (eventLogRoot, 
CoreEventLog.Log.ToLower ());
-                       }
-               }
-
-               private int GetNewIndex () {
-                       // our file names are one-based
-                       int maxIndex = 0;
-                       string[] logFiles = Directory.GetFiles (FileStore, 
"*.log");
-                       for (int i = 0; i < logFiles.Length; i++) {
-                               try {
-                                       string file = logFiles[i];
-                                       int index = int.Parse 
(Path.GetFileNameWithoutExtension (
-                                               file), 
CultureInfo.InvariantCulture);
-                                       if (index > maxIndex)
-                                               maxIndex = index;
-                               } catch {
-                               }
-                       }
-                       return ++maxIndex;
-               }
-       }
-}

Deleted: trunk/mcs/class/System/System.Diagnostics/Win32EventLog.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/Win32EventLog.cs  2006-08-14 
05:32:31 UTC (rev 63703)
+++ trunk/mcs/class/System/System.Diagnostics/Win32EventLog.cs  2006-08-14 
06:00:46 UTC (rev 63704)
@@ -1,230 +0,0 @@
-//
-// System.Diagnostics.Win32EventLog.cs
-//
-// Author:
-//     Gert Driesen <[EMAIL PROTECTED]>
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-//
-// 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;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-namespace System.Diagnostics
-{
-       internal class Win32EventLog : EventLogImpl
-       {
-               private int _oldestEventLogEntry = -1;
-
-               public Win32EventLog (EventLog coreEventLog) : base 
(coreEventLog)
-               {
-               }
-
-               public override void BeginInit () { }
-
-               public override void Clear () {
-                       IntPtr hEventLog = OpenEventLog ();
-                       int ret = PInvoke.ClearEventLog (hEventLog, null);
-                       if (ret != 1) {
-                               throw new Win32Exception 
(Marshal.GetLastWin32Error ());
-                       }
-                       CloseEventLog (hEventLog);
-               }
-
-               public override void Close () {
-                       // we don't hold any unmanaged resources
-               }
-
-               public override void Dispose (bool disposing) {
-                       Close ();
-               }
-
-               public override void EndInit () { }
-
-               public override EventLogEntry[] GetEntries ()
-               {
-                       return new EventLogEntry[0];
-               }
-
-               protected override int GetEntryCount ()
-               {
-                       IntPtr hEventLog = OpenEventLog ();
-                       try {
-                               int entryCount = 0;
-                               int retVal = PInvoke.GetNumberOfEventLogRecords 
(hEventLog, ref entryCount);
-                               if (retVal != 1) {
-                                       throw new Win32Exception 
(Marshal.GetLastWin32Error ());
-                               }
-                               return entryCount;
-                       } finally {
-                               CloseEventLog (hEventLog);
-                       }
-               }
-
-               [MonoTODO ("Read buffer data")]
-               protected override EventLogEntry GetEntry (int index)
-               {
-                       index += OldestEventLogEntry;
-
-                       IntPtr hEventLog = OpenEventLog ();
-                       try {
-                               int bytesRead = 0;
-                               int minBufferNeeded = 0;
-                               byte[] buffer = new byte[0x7ffff]; // according 
to MSDN this is the max size of the buffer
-
-                               int ret = PInvoke.ReadEventLog (hEventLog, 
ReadFlags.Seek |
-                                       ReadFlags.ForwardsRead, index, buffer, 
buffer.Length,
-                                       ref bytesRead, ref minBufferNeeded);
-                               if (ret != 1) {
-                                       throw new InvalidOperationException 
("Event log cannot be read.");
-                               }
-
-                               // TODO read data from buffer and construct 
EventLogEntry !!!!!!!!!!!!
-                               return null;
-                       } finally {
-                               CloseEventLog (hEventLog);
-                       }
-               }
-
-               [MonoTODO]
-               protected override string GetLogDisplayName ()
-               {
-                       return CoreEventLog.Log;
-               }
-
-               protected override void WriteEventLogEntry (EventLogEntry entry)
-               {
-                       IntPtr hEventLog = OpenEventLog ();
-                       try {
-                               byte[] rawData = (entry.Data == null) ? new 
byte[0] : entry.Data;
-                               int ret = PInvoke.ReportEvent (hEventLog, 
(ushort) entry.EntryType,
-                                       (ushort) entry.CategoryNumber, (uint) 
entry.EventID, IntPtr.Zero,
-                                       (ushort) 1, (uint) rawData.Length, new 
string[] { entry.Message },
-                                       rawData);
-                               if (ret != 1) {
-                                       throw new Win32Exception 
(Marshal.GetLastWin32Error ());
-                               }
-                       } finally {
-                               CloseEventLog (hEventLog);
-                       }
-               }
-
-               private int OldestEventLogEntry {
-                       get {
-                               if (_oldestEventLogEntry == -1) {
-                                       IntPtr hEventLog = OpenEventLog ();
-                                       try {
-                                               int ret = 
PInvoke.GetOldestEventLogRecord (hEventLog, ref _oldestEventLogEntry);
-                                               if (ret != 1) {
-                                                       throw new 
Win32Exception (Marshal.GetLastWin32Error ());
-                                               }
-                                       } finally {
-                                               CloseEventLog (hEventLog);
-                                       }
-                               }
-
-                               return _oldestEventLogEntry;
-                       }
-               }
-
-
-               private IntPtr OpenEventLog ()
-               {
-                       string logName = CoreEventLog.GetLogName ();
-                       IntPtr hEventLog = PInvoke.OpenEventLog 
(CoreEventLog.MachineName,
-                               logName);
-                       if (hEventLog == IntPtr.Zero) {
-                               // TODO: include cause of error
-                               throw new InvalidOperationException 
(string.Format (
-                                       CultureInfo.InvariantCulture, "Event 
Log '{0}' on computer"
-                                       + " '{1}' cannot be opened."));
-                       }
-                       return hEventLog;
-               }
-
-               private void CloseEventLog (IntPtr hEventLog)
-               {
-                       int ret = PInvoke.CloseEventLog (hEventLog);
-                       if (ret != 1) {
-                               throw new Win32Exception 
(Marshal.GetLastWin32Error ());
-                       }
-               }
-
-               private class PInvoke
-               {
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern int ClearEventLog (IntPtr 
hEventLog, string lpBackupFileName);
-
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern int CloseEventLog (IntPtr 
hEventLog);
-
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern int GetNumberOfEventLogRecords 
(IntPtr hEventLog, ref int NumberOfRecords);
-
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern int GetOldestEventLogRecord 
(IntPtr hEventLog, ref int OldestRecord);
-
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern IntPtr OpenEventLog (string 
machineName, string logName);
-
-                       [DllImport ("Advapi32.dll", SetLastError=true)]
-                       public static extern int ReportEvent (IntPtr hHandle, 
ushort wType,
-                               ushort wCategory, uint dwEventID, IntPtr sid, 
ushort wNumStrings,
-                               uint dwDataSize, string[] lpStrings, byte[] 
lpRawData);
-
-                       [DllImport ("advapi32.dll", SetLastError=true)]
-                       public static extern int ReadEventLog (IntPtr 
hEventLog, ReadFlags dwReadFlags, int dwRecordOffset, byte[] buffer, int 
nNumberOfBytesToRead, ref int pnBytesRead, ref int pnMinNumberOfBytesNeeded);
-               }
-
-               private enum ReadFlags
-               {
-                       Sequential = 0x001,
-                       Seek = 0x002,
-                       ForwardsRead = 0x004,
-                       BackwardsRead = 0x008
-               }
-       }
-}
-
-// 
http://msdn.microsoft.com/library/en-us/eventlog/base/eventlogrecord_str.asp:
-//
-// struct EVENTLOGRECORD {
-//     int Length;
-//     int Reserved;
-//     int RecordNumber;
-//     int TimeGenerated;
-//     int TimeWritten;
-//     int EventID;
-//     ushort EventType;
-//     ushort NumStrings;
-//     ushort EventCategory;
-//     ushort ReservedFlags;
-//     int ClosingRecordNumber;
-//     int StringOffset;
-//     int UserSidLength;
-//     int UserSidOffset;
-//     int DataLength;  DWORD DataOffset;
-// }

Modified: trunk/mcs/class/System/System.dll.sources
===================================================================
--- trunk/mcs/class/System/System.dll.sources   2006-08-14 05:32:31 UTC (rev 
63703)
+++ trunk/mcs/class/System/System.dll.sources   2006-08-14 06:00:46 UTC (rev 
63704)
@@ -482,8 +482,6 @@
 System.Diagnostics/TraceListenerCollection.cs
 System.Diagnostics/TraceListener.cs
 System.Diagnostics/TraceSwitch.cs
-System.Diagnostics/UnixEventLog.cs
-System.Diagnostics/Win32EventLog.cs
 System/FileStyleUriParser.cs
 System/FtpStyleUriParser.cs
 System/GenericUriParser.cs

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to