Don't dispose the handler
[mono.git] / mcs / class / System / System.Diagnostics / EventLogPermissionAttribute.cs
1 //
2 // System.Diagnostics.EventLogPermissionAttribute.cs
3 //
4 // Authors:
5 //   Jonathan Pryor (jonpryor@vt.edu)
6 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) 2002
9 // (C) 2003 Andreas Nahr
10 //
11
12 using System;
13 using System.Diagnostics;
14 using System.Security;
15 using System.Security.Permissions;
16
17 namespace System.Diagnostics 
18 {
19
20         [AttributeUsage(
21                 AttributeTargets.Assembly | AttributeTargets.Class |
22                 AttributeTargets.Struct | AttributeTargets.Constructor |
23                 AttributeTargets.Method | AttributeTargets.Event)]
24         [Serializable]
25         public class EventLogPermissionAttribute : CodeAccessSecurityAttribute 
26         {
27                 private string machineName;
28                 private EventLogPermissionAccess permissionAccess;
29
30                 public EventLogPermissionAttribute(SecurityAction action)
31                         : base(action)
32                 {
33                         machineName = ".";
34                         permissionAccess = EventLogPermissionAccess.Browse;
35                 }
36
37                 // May throw ArgumentException if computer name is invalid
38                 public string MachineName {
39                         get {return machineName;}
40                         set {
41                                 // TODO check machine name
42                                 machineName = value;
43                         }
44                 }
45
46                 public EventLogPermissionAccess PermissionAccess {
47                         get {return permissionAccess;}
48                         set {permissionAccess = value;}
49                 }
50
51                 public override IPermission CreatePermission()
52                 {
53                         if (base.Unrestricted) {
54                                 return new EventLogPermission (PermissionState.Unrestricted); 
55                         }
56                         return new EventLogPermission (PermissionAccess, MachineName); 
57                 }
58         }
59 }
60