Merge pull request #347 from JamesB7/master
[mono.git] / mcs / class / System / System.Diagnostics / NullEventLog.cs
1 //
2 // NullEventLog.cs
3 //
4 // Author:
5 //   Atsushi Enomoto  <atsushi@ximian.com>
6 //   Gert Driesen  <drieseng@users.sourceforge.net>
7 //
8 // (C) 2006 Novell, Inc.
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System;
33 using System.Diagnostics;
34
35 namespace System.Diagnostics
36 {
37         // Empty implementation that does not need any specific platform
38         // but should be enough to get applications to run that WRITE to eventlog
39         internal class NullEventLog : EventLogImpl
40         {
41                 public NullEventLog (EventLog coreEventLog)
42                         : base (coreEventLog)
43                 {
44                 }
45
46                 public override void BeginInit ()
47                 {
48                 }
49
50                 public override void Clear ()
51                 {
52                 }
53
54                 public override void Close ()
55                 {
56                 }
57
58                 public override void CreateEventSource (EventSourceCreationData sourceData)
59                 {
60                 }
61
62                 public override void Delete (string logName, string machineName)
63                 {
64                 }
65
66                 public override void DeleteEventSource (string source, string machineName)
67                 {
68                 }
69
70                 public override void Dispose (bool disposing)
71                 {
72                 }
73
74                 public override void DisableNotification ()
75                 {
76                 }
77
78                 public override void EnableNotification ()
79                 {
80                 }
81
82                 public override void EndInit ()
83                 {
84                 }
85
86                 public override bool Exists (string logName, string machineName)
87                 {
88                         return true;
89                 }
90
91                 protected override string FormatMessage (string source, uint messageID, string [] replacementStrings)
92                 {
93                         return string.Join (", ", replacementStrings);
94                 }
95
96                 protected override int GetEntryCount ()
97                 {
98                         return 0;
99                 }
100
101                 protected override EventLogEntry GetEntry (int index)
102                 {
103                         return null;
104                 }
105
106                 protected override string GetLogDisplayName ()
107                 {
108                         return CoreEventLog.Log;
109                 }
110
111                 protected override string [] GetLogNames (string machineName)
112                 {
113                         return new string [0];
114                 }
115
116                 public override string LogNameFromSourceName (string source, string machineName)
117                 {
118                         return null;
119                 }
120
121                 public override bool SourceExists (string source, string machineName)
122                 {
123                         return false;
124                 }
125
126                 public override void WriteEntry (string [] replacementStrings, EventLogEntryType type, uint instanceID, short category, byte [] rawData)
127                 {
128                 }
129
130                 public override OverflowAction OverflowAction {
131                         get { return OverflowAction.DoNotOverwrite; }
132                 }
133
134                 public override int MinimumRetentionDays {
135                         get { return int.MaxValue; }
136                 }
137
138                 public override long MaximumKilobytes {
139                         get { return long.MaxValue; }
140                         set { throw new NotSupportedException ("This EventLog implementation does not support setting max kilobytes policy"); }
141                 }
142
143                 public override void ModifyOverflowPolicy (OverflowAction action, int retentionDays)
144                 {
145                         throw new NotSupportedException ("This EventLog implementation does not support modifying overflow policy");
146                 }
147
148                 public override void RegisterDisplayName (string resourceFile, long resourceId)
149                 {
150                         throw new NotSupportedException ("This EventLog implementation does not support registering display name");
151                 }
152         }
153 }