EventLogPermissionAttribute.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Services / Monitoring / system / Diagnosticts / EventLogPermissionAttribute.cs / 1 / EventLogPermissionAttribute.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Diagnostics { 
    using System.ComponentModel; 
    using System.Security;
    using System.Security.Permissions; 

    [
    AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Event, AllowMultiple = true, Inherited = false ),
    Serializable() 
    ]
    public class EventLogPermissionAttribute : CodeAccessSecurityAttribute { 
        private string machineName; 
        private EventLogPermissionAccess permissionAccess;
 
        public EventLogPermissionAttribute(SecurityAction action)
        : base(action) {
            this.machineName = ".";
            this.permissionAccess = EventLogPermissionAccess.Write; 
        }
 
        public string MachineName { 
            get {
                return this.machineName; 
            }

            set {
                if (!SyntaxCheck.CheckMachineName(value)) 
                    throw new ArgumentException(SR.GetString(SR.InvalidProperty, "MachineName", value));
 
                this.machineName = value; 
            }
        } 

        public EventLogPermissionAccess PermissionAccess {
            get {
                return this.permissionAccess; 
            }
 
            set { 
                this.permissionAccess = value;
            } 
        }

        public override IPermission CreatePermission() {
             if (Unrestricted) 
                return new EventLogPermission(PermissionState.Unrestricted);
 
            return new EventLogPermission(this.PermissionAccess, this.MachineName); 

        } 
    }
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Diagnostics { 
    using System.ComponentModel; 
    using System.Security;
    using System.Security.Permissions; 

    [
    AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Event, AllowMultiple = true, Inherited = false ),
    Serializable() 
    ]
    public class EventLogPermissionAttribute : CodeAccessSecurityAttribute { 
        private string machineName; 
        private EventLogPermissionAccess permissionAccess;
 
        public EventLogPermissionAttribute(SecurityAction action)
        : base(action) {
            this.machineName = ".";
            this.permissionAccess = EventLogPermissionAccess.Write; 
        }
 
        public string MachineName { 
            get {
                return this.machineName; 
            }

            set {
                if (!SyntaxCheck.CheckMachineName(value)) 
                    throw new ArgumentException(SR.GetString(SR.InvalidProperty, "MachineName", value));
 
                this.machineName = value; 
            }
        } 

        public EventLogPermissionAccess PermissionAccess {
            get {
                return this.permissionAccess; 
            }
 
            set { 
                this.permissionAccess = value;
            } 
        }

        public override IPermission CreatePermission() {
             if (Unrestricted) 
                return new EventLogPermission(PermissionState.Unrestricted);
 
            return new EventLogPermission(this.PermissionAccess, this.MachineName); 

        } 
    }
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK