EventLogImpl.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // System.Diagnostics.EventLogImpl.cs
  3. //
  4. // Authors:
  5. // Andreas Nahr ([email protected])
  6. //
  7. // (C) 2003 Andreas Nahr
  8. //
  9. using System;
  10. using System.Diagnostics;
  11. using System.ComponentModel;
  12. using System.ComponentModel.Design;
  13. namespace System.Diagnostics
  14. {
  15. // FIXME set a symbol for every implementation and include the implementation
  16. #if (EVENTLOG_WIN32)
  17. // TODO implement the EventLog for Win32 platforms
  18. #elif (EVENTLOG_GENERIC)
  19. // TODO implement a generic (XML - based?) Eventlog for non - Win32 platforms
  20. #else
  21. // Empty implementation that does not need any specific platform
  22. // but should be enough to get applications to run that WRITE to eventlog
  23. internal class EventLogImpl
  24. {
  25. public EventLogImpl (EventLog coreEventLog)
  26. {
  27. }
  28. public static event EntryWrittenEventHandler EntryWritten;
  29. public EventLogEntryCollection Entries {
  30. get {return new EventLogEntryCollection ();}
  31. }
  32. public string LogDisplayName {
  33. get {return "";}
  34. }
  35. public void BeginInit () {}
  36. public void Clear () {}
  37. public void Close () {}
  38. public static void CreateEventSource (string source, string logName, string machineName) {}
  39. public static void Delete (string logName, string machineName) {}
  40. public static void DeleteEventSource (string source, string machineName) {}
  41. public void Dispose (bool disposing) {}
  42. public void EndInit () {}
  43. public static bool Exists (string logName, string machineName)
  44. {
  45. return false;
  46. }
  47. public static EventLog[] GetEventLogs (string machineName)
  48. {
  49. return new EventLog[0];
  50. }
  51. public static string LogNameFromSourceName (string source, string machineName)
  52. {
  53. return String.Empty;
  54. }
  55. public static bool SourceExists (string source, string machineName)
  56. {
  57. return false;
  58. }
  59. public void WriteEntry (string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
  60. {
  61. WriteEntry ("", message, type, eventID, category, rawData);
  62. }
  63. public static void WriteEntry (string source, string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
  64. {
  65. EventLogEntry Entry;
  66. Entry = new EventLogEntry ("", category, 0, eventID, message, source,
  67. "", "", type, DateTime.Now, DateTime.Now, rawData, null);
  68. if (EntryWritten != null)
  69. EntryWritten (null, new EntryWrittenEventArgs (Entry));
  70. }
  71. }
  72. #endif
  73. }