Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Driesen <drieseng@users.sourceforge.net>2006-08-27 13:38:11 +0400
committerGert Driesen <drieseng@users.sourceforge.net>2006-08-27 13:38:11 +0400
commitc86b5de9425383f9e5e2c5eabcf19c3939d2f2fe (patch)
tree8feeed041bbc573d55a8f1b0cd11f3e01930ccac /mcs/class/System/System.Diagnostics/Win32EventLog.cs
parent256c358fd0dbe63cec33ddc5f09982d80350aaab (diff)
* NullEventLog.cs: Added dummy GetLogNames implementation.
* EventLogImpl.cs: Moved GetEventLogs implementation to base class. Added abstract GetLogNames method. Added ValidateCustomerLogName method which should be called by eventlog providers when creating a new log to ensure the significant part of the log name is unique, does not match any of the special log names and does not match an exist event source. * Win32EventLog.cs: Validate customer log name when creating new log. Moved GetEventLogs implementation to base class. Added GetLogNames method. * LocalFileEventLog.cs: Merged CreateLogStore into CreateEventSource. Validate customer log name when creating new log. Moved GetEventLogs implementation to base class. Added GetLogNames method. * EventLogTest.cs: Added tests for log name validation in CreateEventSource. svn path=/trunk/mcs/; revision=64429
Diffstat (limited to 'mcs/class/System/System.Diagnostics/Win32EventLog.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/Win32EventLog.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/mcs/class/System/System.Diagnostics/Win32EventLog.cs b/mcs/class/System/System.Diagnostics/Win32EventLog.cs
index 913abbc144c..05c248307ad 100644
--- a/mcs/class/System/System.Diagnostics/Win32EventLog.cs
+++ b/mcs/class/System/System.Diagnostics/Win32EventLog.cs
@@ -82,6 +82,9 @@ namespace System.Diagnostics
try {
logKey = eventLogKey.OpenSubKey (sourceData.LogName, true);
if (logKey == null) {
+ ValidateCustomerLogName (sourceData.LogName,
+ sourceData.MachineName);
+
logKey = eventLogKey.CreateSubKey (sourceData.LogName);
logKey.SetValue ("Sources", new string [] { sourceData.LogName,
sourceData.Source });
@@ -353,28 +356,22 @@ namespace System.Diagnostics
}
}
- public override 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;
- }
- }
-
[MonoTODO]
protected override string GetLogDisplayName ()
{
return CoreEventLog.Log;
}
+ protected override string [] GetLogNames (string machineName)
+ {
+ using (RegistryKey eventLogKey = GetEventLogKey (machineName, true)) {
+ if (eventLogKey == null)
+ return new string [0];
+
+ return eventLogKey.GetSubKeyNames ();
+ }
+ }
+
public override string LogNameFromSourceName (string source, string machineName)
{
using (RegistryKey logKey = FindLogKeyBySource (source, machineName, false)) {