DeploymentSectionCache.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / Orcas / RTM / ndp / fx / src / xsp / System / Web / Extensions / ui / DeploymentSectionCache.cs / 1 / DeploymentSectionCache.cs

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

namespace System.Web.UI { 
    using System; 
    using System.Configuration;
    using System.Security; 
    using System.Security.Permissions;
    using System.Web.Configuration;

    // DeploymentSection can only be defined in machine.config, so it is safe to cache statically in the application 
    internal sealed class DeploymentSectionCache : IDeploymentSection {
        private static readonly DeploymentSectionCache _instance = new DeploymentSectionCache(); 
        // Value is cached statically, because DeploymentSectionCache is a Singleton. 
        private bool? _retail;
 
        private DeploymentSectionCache() {
        }

        public static DeploymentSectionCache Instance { 
            get {
                return _instance; 
            } 
        }
 
        public bool Retail {
            get {
                if (_retail == null) {
                    _retail = GetRetailFromConfig(); 
                }
                return _retail.Value; 
            } 
        }
 
        [
        ConfigurationPermission(SecurityAction.Assert, Unrestricted = true),
        SecurityCritical(),
        SecurityTreatAsSafe(), 
        ]
        private static bool GetRetailFromConfig() { 
            DeploymentSection section = (DeploymentSection)WebConfigurationManager.GetSection("system.web/deployment"); 
            return section.Retail;
        } 
    }
}

// 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