2004-05-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System / System.Diagnostics / EventLogPermissionAttribute.cs
index 17eb6ca99357b357460917851e15c186bd9f4a63..d6db335d9dfca57119106d889772d1ac813c8088 100644 (file)
@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor (jonpryor@vt.edu)
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -12,36 +14,46 @@ using System.Diagnostics;
 using System.Security;
 using System.Security.Permissions;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
        [AttributeUsage(
                AttributeTargets.Assembly | AttributeTargets.Class |
                AttributeTargets.Struct | AttributeTargets.Constructor |
                AttributeTargets.Method | AttributeTargets.Event)]
        [Serializable]
-       [MonoTODO("Just Stubbed Out")]
-       public class EventLogPermissionAttribute : CodeAccessSecurityAttribute {
+       public class EventLogPermissionAttribute : CodeAccessSecurityAttribute 
+       {
+               private string machineName;
+               private EventLogPermissionAccess permissionAccess;
 
                public EventLogPermissionAttribute(SecurityAction action)
                        : base(action)
                {
+                       machineName = ".";
+                       permissionAccess = EventLogPermissionAccess.Browse;
+               }
+
+               // May throw ArgumentException if computer name is invalid
+               public string MachineName {
+                       get {return machineName;}
+                       set {
+                               // TODO check machine name
+                               machineName = value;
+                       }
+               }
+
+               public EventLogPermissionAccess PermissionAccess {
+                       get {return permissionAccess;}
+                       set {permissionAccess = value;}
                }
 
-//             // May throw ArgumentException if computer name is invalid
-//             public string MachineName {
-//                     get {throw new NotImplementedException();}
-//                     set {throw new NotImplementedException();}
-//             }
-//
-//             public EventLogPermissionAccess PermissionAccess {
-//                     get {throw new NotImplementedException();}
-//                     set {throw new NotImplementedException();}
-//             }
-//
-               [MonoTODO]
                public override IPermission CreatePermission()
                {
-                       throw new NotImplementedException();
+                       if (base.Unrestricted) {
+                               return new EventLogPermission (PermissionState.Unrestricted); 
+                       }
+                       return new EventLogPermission (PermissionAccess, MachineName); 
                }
        }
 }