EventLogImpl.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // System.Diagnostics.EventLogImpl.cs
  3. //
  4. // Authors:
  5. // Andreas Nahr ([email protected])
  6. //
  7. // (C) 2003 Andreas Nahr
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Diagnostics;
  31. using System.ComponentModel;
  32. using System.ComponentModel.Design;
  33. namespace System.Diagnostics
  34. {
  35. // FIXME set a symbol for every implementation and include the implementation
  36. #if (EVENTLOG_WIN32)
  37. // TODO implement the EventLog for Win32 platforms
  38. #elif (EVENTLOG_GENERIC)
  39. // TODO implement a generic (XML - based?) Eventlog for non - Win32 platforms
  40. #else
  41. // Empty implementation that does not need any specific platform
  42. // but should be enough to get applications to run that WRITE to eventlog
  43. internal class EventLogImpl
  44. {
  45. public EventLogImpl (EventLog coreEventLog)
  46. {
  47. }
  48. public static event EntryWrittenEventHandler EntryWritten;
  49. public EventLogEntryCollection Entries {
  50. get {return new EventLogEntryCollection ();}
  51. }
  52. public string LogDisplayName {
  53. get {return "";}
  54. }
  55. public void BeginInit () {}
  56. public void Clear () {}
  57. public void Close () {}
  58. public static void CreateEventSource (string source, string logName, string machineName) {}
  59. public static void Delete (string logName, string machineName) {}
  60. public static void DeleteEventSource (string source, string machineName) {}
  61. public void Dispose (bool disposing) {}
  62. public void EndInit () {}
  63. public static bool Exists (string logName, string machineName)
  64. {
  65. return false;
  66. }
  67. public static EventLog[] GetEventLogs (string machineName)
  68. {
  69. return new EventLog[0];
  70. }
  71. public static string LogNameFromSourceName (string source, string machineName)
  72. {
  73. return String.Empty;
  74. }
  75. public static bool SourceExists (string source, string machineName)
  76. {
  77. return false;
  78. }
  79. public void WriteEntry (string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
  80. {
  81. WriteEntry ("", message, type, eventID, category, rawData);
  82. }
  83. public static void WriteEntry (string source, string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
  84. {
  85. EventLogEntry Entry;
  86. Entry = new EventLogEntry ("", category, 0, eventID, message, source,
  87. "", "", type, DateTime.Now, DateTime.Now, rawData, null);
  88. if (EntryWritten != null)
  89. EntryWritten (null, new EntryWrittenEventArgs (Entry));
  90. }
  91. }
  92. #endif
  93. }