// (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
+// "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.Diagnostics;
using System.ComponentModel;
using System.ComponentModel.Design;
-namespace System.Diagnostics {
-
- [MonoTODO("This class is just stubbed out")]
- [DefaultEvent ("EntryWritten"), DesignerCategory ("Category"), InstallerType (typeof (EventLogInstaller))]
- #if (NET_1_0)
- [Designer ("Microsoft.VisualStudio.Install.EventLogInstallableComponentDesigner, Microsoft.VisualStudio, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (IDesigner))]
- #endif
- #if (NET_1_1)
- [Designer ("Microsoft.VisualStudio.Install.EventLogInstallableComponentDesigner, Microsoft.VisualStudio, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (IDesigner))]
- #endif
+namespace System.Diagnostics
+{
+ [DefaultEvent ("EntryWritten")]
+ [InstallerType (typeof (EventLogInstaller))]
+ [Designer ("Microsoft.VisualStudio.Install.EventLogInstallableComponentDesigner, " + Consts.AssemblyMicrosoft_VisualStudio)]
public class EventLog : Component, ISupportInitialize
{
private string source;
private string logName;
private string machineName;
+ private bool doRaiseEvents = false;
+ private ISynchronizeInvoke synchronizingObject = null;
+
+ private EventLogImpl Impl;
- public EventLog() : this ("")
+ public EventLog()
+ : this ("")
{
}
- public EventLog(string logName) : this (logName, "")
+ public EventLog(string logName)
+ : this (logName, ".")
{
}
{
}
- public EventLog(string logName, string machineName,
- string source)
+ public EventLog(string logName, string machineName, string source)
{
this.source = source;
this.machineName = machineName;
this.logName = logName;
+
+ this.Impl = new EventLogImpl (this);
+ EventLogImpl.EntryWritten += new EntryWrittenEventHandler (EntryWrittenHandler);
+ }
+
+ private void EntryWrittenHandler (object sender, EntryWrittenEventArgs e)
+ {
+ if (doRaiseEvents)
+ OnEntryWritten (e.Entry);
}
- [MonoTODO]
[Browsable (false), DefaultValue (false)]
[MonitoringDescription ("If enabled raises event when a log is written.")]
public bool EnableRaisingEvents {
- get {return false;}
- set {/* ignore */}
+ get {return doRaiseEvents;}
+ set {doRaiseEvents = value;}
}
- [MonoTODO]
[Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[MonitoringDescription ("The entries in the log.")]
public EventLogEntryCollection Entries {
- get {return null;}
+ get {return Impl.Entries;}
}
- [MonoTODO]
[ReadOnly (true), DefaultValue (""), RecommendedAsConfigurable (true)]
- #if (NET_1_0)
- [TypeConverter ("System.Diagnostics.Design.LogConverter, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- #endif
- #if (NET_1_1)
- [TypeConverter ("System.Diagnostics.Design.LogConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- #endif
+ [TypeConverter ("System.Diagnostics.Design.LogConverter, " + Consts.AssemblySystem_Design)]
[MonitoringDescription ("Name of the log that is read and written.")]
public string Log {
get {return logName;}
set {logName = value;}
}
- [MonoTODO]
[Browsable (false)]
public string LogDisplayName {
- get {return "";}
+ get {return Impl.LogDisplayName;}
}
- [MonoTODO]
[ReadOnly (true), DefaultValue ("."), RecommendedAsConfigurable (true)]
[MonitoringDescription ("Name of the machine that this log get written to.")]
public string MachineName {
get {return machineName;}
- set {/* ignore */}
+ set {machineName = value;}
}
- [MonoTODO]
[ReadOnly (true), DefaultValue (""), RecommendedAsConfigurable (true)]
- #if (NET_1_0)
- [TypeConverter ("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- #endif
- #if (NET_1_1)
- [TypeConverter ("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- #endif
+ [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
[MonitoringDescription ("The application name that writes the log.")]
public string Source {
get {return source;}
- set {/* ignore */}
+ set {source = value;}
}
- [MonoTODO]
[Browsable (false), DefaultValue (null)]
[MonitoringDescription ("An object that synchronizes event handler calls.")]
public ISynchronizeInvoke SynchronizingObject {
- get {return null;}
- set {/* ignore */}
+ get {return synchronizingObject;}
+ set {synchronizingObject = value;}
}
- [MonoTODO]
public void BeginInit()
{
- throw new NotImplementedException ();
+ Impl.BeginInit();
}
- [MonoTODO]
public void Clear()
{
- throw new NotImplementedException ();
+ Impl.Clear();
}
- [MonoTODO]
public void Close()
{
- throw new NotImplementedException ();
+ Impl.Close();
}
public static void CreateEventSource(string source, string logName)
CreateEventSource (source, logName, ".");
}
- [MonoTODO]
public static void CreateEventSource(string source,
string logName,
string machineName)
{
- throw new NotImplementedException ();
+ EventLogImpl.CreateEventSource (source, logName, machineName);
}
public static void Delete(string logName)
Delete (logName, ".");
}
- [MonoTODO]
public static void Delete(string logName, string machineName)
{
- throw new NotImplementedException ();
+ EventLogImpl.Delete (logName, machineName);
}
public static void DeleteEventSource(string source)
DeleteEventSource (source, ".");
}
- [MonoTODO]
public static void DeleteEventSource(string source,
string machineName)
{
- throw new NotImplementedException ();
+ EventLogImpl.DeleteEventSource (source, machineName);
}
- [MonoTODO]
protected override void Dispose(bool disposing)
{
- throw new NotImplementedException ();
+ Impl.Dispose (disposing);
}
- [MonoTODO]
public void EndInit()
{
- throw new NotImplementedException ();
+ Impl.EndInit();
}
public static bool Exists(string logName)
return Exists (logName, ".");
}
- [MonoTODO]
public static bool Exists(string logName, string machineName)
{
- throw new NotImplementedException ();
+ return EventLogImpl.Exists (logName, machineName);
}
public static EventLog[] GetEventLogs()
return GetEventLogs (".");
}
- [MonoTODO]
public static EventLog[] GetEventLogs(string machineName)
{
- throw new NotImplementedException ();
+ return EventLogImpl.GetEventLogs (machineName);
}
- [MonoTODO]
public static string LogNameFromSourceName(string source,
string machineName)
{
- throw new NotImplementedException ();
+ return EventLogImpl.LogNameFromSourceName (source, machineName);
}
public static bool SourceExists(string source)
return SourceExists (source, ".");
}
- [MonoTODO]
public static bool SourceExists(string source, string machineName)
{
- throw new NotImplementedException ();
+ return EventLogImpl.SourceExists (source, machineName);
}
public void WriteEntry(string message)
WriteEntry (message, type, eventID, category, null);
}
- [MonoTODO]
public void WriteEntry(string message, EventLogEntryType type,
int eventID,
short category, byte[] rawData)
{
- throw new NotImplementedException ();
+ Impl.WriteEntry (message, type, eventID, category, rawData);
}
public static void WriteEntry(string source, string message)
WriteEntry (source, message, EventLogEntryType.Information, eventID, category, null);
}
- [MonoTODO]
public static void WriteEntry(string source, string message,
EventLogEntryType type, int eventID, short category,
byte[] rawData)
{
- throw new NotImplementedException ();
+ EventLogImpl.WriteEntry (source, message, type, eventID, category, rawData);
+ }
+
+ internal void OnEntryWritten (EventLogEntry newEntry)
+ {
+ if (EntryWritten != null)
+ EntryWritten (this, new EntryWrittenEventArgs (newEntry));
}
- [MonitoringDescription ("Raised for each eventlog entry written.")]
+ [MonitoringDescription ("Raised for each EventLog entry written.")]
public event EntryWrittenEventHandler EntryWritten;
}
}