PrintingPermissionAttribute.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Printing / PrintingPermissionAttribute.cs / 1 / PrintingPermissionAttribute.cs

                            /* 
 * Copyright (c) 2000 Microsoft Corporation.  All Rights Reserved.
 * Microsoft Confidential.
 */
 
namespace System.Drawing.Printing {
    using System; 
    using System.Security; 
    using System.Security.Permissions;
    using System.IO; 
    using System.Runtime.Serialization;
    using System.Reflection;
    using System.Collections;
    using System.Diagnostics.CodeAnalysis; 

    ///  
    [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] 
    public sealed class PrintingPermissionAttribute : CodeAccessSecurityAttribute {
        PrintingPermissionLevel level; 

        /// 
        public PrintingPermissionAttribute(SecurityAction action) : base(action) {
        } 

 
        ///  
        public PrintingPermissionLevel Level {
            get { 
                return level;
            }

            set { 
                if (value < PrintingPermissionLevel.NoPrinting || value > PrintingPermissionLevel.AllPrinting) {
                    throw new ArgumentException(SR.GetString(SR.PrintingPermissionAttributeInvalidPermissionLevel), "value"); 
                } 
                level = value;
            } 
        }

        /// 
        [SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")] 
        public override IPermission CreatePermission() {
            if (Unrestricted) { 
                return new PrintingPermission(PermissionState.Unrestricted); 
            }
            else { 
                return new PrintingPermission(level);
            }
        }
    } 
}
 
// File provided for Reference Use Only by Microsoft Corporation (c) 2007. 
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

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