Code:
                         / Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / Configuration / Compiler.cs / 1 / Compiler.cs
                        
                        
                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//  
//----------------------------------------------------------------------------- 
namespace System.Web.Configuration { 
    using System; 
    using System.Xml;
    using System.Configuration; 
    using System.Collections.Specialized;
    using System.Collections;
    using System.Globalization;
    using System.IO; 
    using System.Text;
    using System.Web.Compilation; 
    using System.Reflection; 
    using System.Web.Hosting;
    using System.Web.UI; 
    using System.CodeDom.Compiler;
    using System.Web.Util;
    using System.ComponentModel;
    using System.Security.Permissions; 
    // CompilerCollection 
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
    public sealed class Compiler : ConfigurationElement {
        private const string compilerOptionsAttribName = "compilerOptions"; 
        private static ConfigurationPropertyCollection _properties;
        private static readonly ConfigurationProperty _propLanguage =
            new ConfigurationProperty("language", typeof(string), String.Empty, ConfigurationPropertyOptions.None ); 
        private static readonly ConfigurationProperty _propExtension =
            new ConfigurationProperty("extension", typeof(string), String.Empty, ConfigurationPropertyOptions.None); 
        private static readonly ConfigurationProperty _propType = 
            new ConfigurationProperty("type", typeof(string), String.Empty, ConfigurationPropertyOptions.IsRequired);
        private static readonly ConfigurationProperty _propWarningLevel = 
            new ConfigurationProperty("warningLevel",
                                        typeof(int),
                                        0,
                                        null, 
                                        new IntegerValidator(0, 4),
                                        ConfigurationPropertyOptions.None); 
        private static readonly ConfigurationProperty _propCompilerOptions = 
            new ConfigurationProperty(compilerOptionsAttribName, typeof(string), String.Empty, ConfigurationPropertyOptions.None);
 
        private CompilerType _compilerType;
        static Compiler() {
            // Property initialization 
            _properties = new ConfigurationPropertyCollection();
            _properties.Add(_propLanguage); 
            _properties.Add(_propExtension); 
            _properties.Add(_propType);
            _properties.Add(_propWarningLevel); 
            _properties.Add(_propCompilerOptions);
        }
        internal Compiler() { 
        }
 
        public Compiler(String compilerOptions, String extension, String language, String type, int warningLevel) 
            : this() {
            base[_propCompilerOptions] = compilerOptions; 
            base[_propExtension] = extension;
            base[_propLanguage] = language;
            base[_propType] = type;
            base[_propWarningLevel] = warningLevel; 
        }
 
        protected override ConfigurationPropertyCollection Properties { 
            get {
                return _properties; 
            }
        }
        [ConfigurationProperty("language", DefaultValue = "", IsRequired = true, IsKey = true)] 
        public string Language {
            get { 
                return (string)base[_propLanguage]; 
            }
            // Remove to satisfy defect number 178343 
            //set
            //{
            //    base[_propLanguage] = value;
            //} 
        }
 
        [ConfigurationProperty("extension", DefaultValue = "")] 
        public string Extension {
            get { 
                return (string)base[_propExtension];
            }
            // Remove to satisfy defect number 178343
            //set 
            //{
            //    base[_propExtension] = value; 
            //} 
        }
 
        [ConfigurationProperty("type", IsRequired = true, DefaultValue = "")]
        public string Type {
            get {
                return (string)base[_propType]; 
            }
            // Remove to satisfy defect number 178343 
            //set 
            //{
            //    base[_propType] = value; 
            //}
        }
        internal CompilerType CompilerTypeInternal { 
            get {
                if (_compilerType == null) { 
                    lock (this) { 
                        if (_compilerType == null) {
                            Type codeDomProviderType = CompilationUtil.LoadTypeWithChecks( 
                            Type, typeof(CodeDomProvider), null, this, "type");
                            System.CodeDom.Compiler.CompilerParameters compilParams = new CompilerParameters();
                            compilParams.WarningLevel = WarningLevel; 
                            // Need to be false if the warning level is 0 
                            compilParams.TreatWarningsAsErrors = (WarningLevel > 0); 
                            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678) 
                            string compilerOptions = CompilerOptions;
                            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
                            CompilationUtil.CheckCompilerOptionsAllowed(compilerOptions, true /*config*/, 
                                ElementInformation.Properties[compilerOptionsAttribName].Source,
                                ElementInformation.Properties[compilerOptionsAttribName].LineNumber); 
 
                            compilParams.CompilerOptions = compilerOptions;
 
                            _compilerType = new CompilerType(codeDomProviderType, compilParams);
                        }
                    }
                } 
                return _compilerType; 
            } 
        }
 
        [ConfigurationProperty("warningLevel", DefaultValue = 0)]
        [IntegerValidator(MinValue = 0, MaxValue = 4)]
        public int WarningLevel {
            get { 
                return (int)base[_propWarningLevel];
            } 
            // Remove to satisfy defect number 178343 
            //set
            //{ 
            //    base[_propWarningLevel] = value;
            //}
        }
 
        [ConfigurationProperty(compilerOptionsAttribName, DefaultValue = "")]
        public string CompilerOptions { 
            get { 
                return (string)base[_propCompilerOptions];
            } 
            // Remove to satisfy defect number 178343
            //set
            //{
            //    base[_propCompilerOptions] = value; 
            //}
        } 
 
    } // class Compiler
} 
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//  
//----------------------------------------------------------------------------- 
namespace System.Web.Configuration { 
    using System; 
    using System.Xml;
    using System.Configuration; 
    using System.Collections.Specialized;
    using System.Collections;
    using System.Globalization;
    using System.IO; 
    using System.Text;
    using System.Web.Compilation; 
    using System.Reflection; 
    using System.Web.Hosting;
    using System.Web.UI; 
    using System.CodeDom.Compiler;
    using System.Web.Util;
    using System.ComponentModel;
    using System.Security.Permissions; 
    // CompilerCollection 
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
    public sealed class Compiler : ConfigurationElement {
        private const string compilerOptionsAttribName = "compilerOptions"; 
        private static ConfigurationPropertyCollection _properties;
        private static readonly ConfigurationProperty _propLanguage =
            new ConfigurationProperty("language", typeof(string), String.Empty, ConfigurationPropertyOptions.None ); 
        private static readonly ConfigurationProperty _propExtension =
            new ConfigurationProperty("extension", typeof(string), String.Empty, ConfigurationPropertyOptions.None); 
        private static readonly ConfigurationProperty _propType = 
            new ConfigurationProperty("type", typeof(string), String.Empty, ConfigurationPropertyOptions.IsRequired);
        private static readonly ConfigurationProperty _propWarningLevel = 
            new ConfigurationProperty("warningLevel",
                                        typeof(int),
                                        0,
                                        null, 
                                        new IntegerValidator(0, 4),
                                        ConfigurationPropertyOptions.None); 
        private static readonly ConfigurationProperty _propCompilerOptions = 
            new ConfigurationProperty(compilerOptionsAttribName, typeof(string), String.Empty, ConfigurationPropertyOptions.None);
 
        private CompilerType _compilerType;
        static Compiler() {
            // Property initialization 
            _properties = new ConfigurationPropertyCollection();
            _properties.Add(_propLanguage); 
            _properties.Add(_propExtension); 
            _properties.Add(_propType);
            _properties.Add(_propWarningLevel); 
            _properties.Add(_propCompilerOptions);
        }
        internal Compiler() { 
        }
 
        public Compiler(String compilerOptions, String extension, String language, String type, int warningLevel) 
            : this() {
            base[_propCompilerOptions] = compilerOptions; 
            base[_propExtension] = extension;
            base[_propLanguage] = language;
            base[_propType] = type;
            base[_propWarningLevel] = warningLevel; 
        }
 
        protected override ConfigurationPropertyCollection Properties { 
            get {
                return _properties; 
            }
        }
        [ConfigurationProperty("language", DefaultValue = "", IsRequired = true, IsKey = true)] 
        public string Language {
            get { 
                return (string)base[_propLanguage]; 
            }
            // Remove to satisfy defect number 178343 
            //set
            //{
            //    base[_propLanguage] = value;
            //} 
        }
 
        [ConfigurationProperty("extension", DefaultValue = "")] 
        public string Extension {
            get { 
                return (string)base[_propExtension];
            }
            // Remove to satisfy defect number 178343
            //set 
            //{
            //    base[_propExtension] = value; 
            //} 
        }
 
        [ConfigurationProperty("type", IsRequired = true, DefaultValue = "")]
        public string Type {
            get {
                return (string)base[_propType]; 
            }
            // Remove to satisfy defect number 178343 
            //set 
            //{
            //    base[_propType] = value; 
            //}
        }
        internal CompilerType CompilerTypeInternal { 
            get {
                if (_compilerType == null) { 
                    lock (this) { 
                        if (_compilerType == null) {
                            Type codeDomProviderType = CompilationUtil.LoadTypeWithChecks( 
                            Type, typeof(CodeDomProvider), null, this, "type");
                            System.CodeDom.Compiler.CompilerParameters compilParams = new CompilerParameters();
                            compilParams.WarningLevel = WarningLevel; 
                            // Need to be false if the warning level is 0 
                            compilParams.TreatWarningsAsErrors = (WarningLevel > 0); 
                            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678) 
                            string compilerOptions = CompilerOptions;
                            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
                            CompilationUtil.CheckCompilerOptionsAllowed(compilerOptions, true /*config*/, 
                                ElementInformation.Properties[compilerOptionsAttribName].Source,
                                ElementInformation.Properties[compilerOptionsAttribName].LineNumber); 
 
                            compilParams.CompilerOptions = compilerOptions;
 
                            _compilerType = new CompilerType(codeDomProviderType, compilParams);
                        }
                    }
                } 
                return _compilerType; 
            } 
        }
 
        [ConfigurationProperty("warningLevel", DefaultValue = 0)]
        [IntegerValidator(MinValue = 0, MaxValue = 4)]
        public int WarningLevel {
            get { 
                return (int)base[_propWarningLevel];
            } 
            // Remove to satisfy defect number 178343 
            //set
            //{ 
            //    base[_propWarningLevel] = value;
            //}
        }
 
        [ConfigurationProperty(compilerOptionsAttribName, DefaultValue = "")]
        public string CompilerOptions { 
            get { 
                return (string)base[_propCompilerOptions];
            } 
            // Remove to satisfy defect number 178343
            //set
            //{
            //    base[_propCompilerOptions] = value; 
            //}
        } 
 
    } // class Compiler
} 
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        
                        
                        
                        
                    Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataStreams.cs
- CacheAxisQuery.cs
- counter.cs
- TableProviderWrapper.cs
- WorkflowServiceHost.cs
- NativeRecognizer.cs
- ClipboardProcessor.cs
- DataBoundControl.cs
- XmlHierarchicalDataSourceView.cs
- ManualResetEvent.cs
- MouseGestureConverter.cs
- DataGridViewCellCancelEventArgs.cs
- LockCookie.cs
- HelpInfo.cs
- util.cs
- indexingfiltermarshaler.cs
- ByteArrayHelperWithString.cs
- UICuesEvent.cs
- DataGridCommandEventArgs.cs
- COM2Enum.cs
- FunctionImportMapping.cs
- OraclePermission.cs
- KeyValueInternalCollection.cs
- SourceChangedEventArgs.cs
- ObjectContextServiceProvider.cs
- ListSourceHelper.cs
- X509Chain.cs
- InputProviderSite.cs
- CodeConstructor.cs
- ViewDesigner.cs
- QueryableDataSourceView.cs
- CodeValidator.cs
- WebPartsPersonalization.cs
- ResourceSet.cs
- HyperLinkField.cs
- DesignColumnCollection.cs
- DataBindingCollectionConverter.cs
- HeaderElement.cs
- FormsAuthenticationUser.cs
- SamlAuthorizationDecisionStatement.cs
- XmlNamespaceMappingCollection.cs
- LocalizableAttribute.cs
- PipeStream.cs
- SiteMapHierarchicalDataSourceView.cs
- SHA384.cs
- SettingsPropertyIsReadOnlyException.cs
- Dictionary.cs
- TreeViewItemAutomationPeer.cs
- XmlDocumentFragment.cs
- XmlQueryRuntime.cs
- Parsers.cs
- BindingCollection.cs
- OpenFileDialog.cs
- SystemParameters.cs
- XPathAxisIterator.cs
- DbMetaDataCollectionNames.cs
- SecureConversationServiceCredential.cs
- XmlSchemaValidationException.cs
- SubqueryTrackingVisitor.cs
- TreeIterator.cs
- ActivitySurrogateSelector.cs
- TrustLevel.cs
- ProgressBarHighlightConverter.cs
- WebConfigurationHostFileChange.cs
- EncodingNLS.cs
- HotCommands.cs
- UriParserTemplates.cs
- QueryOperationResponseOfT.cs
- shaperfactoryquerycachekey.cs
- ZipPackage.cs
- EntityDataSourceUtil.cs
- TextFormatterImp.cs
- PageParser.cs
- ListView.cs
- ComponentEditorForm.cs
- ImageFormatConverter.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- PersistenceProviderFactory.cs
- ProfileModule.cs
- FrameDimension.cs
- WindowsHyperlink.cs
- ThemeInfoAttribute.cs
- SqlDataSourceSelectingEventArgs.cs
- JavaScriptObjectDeserializer.cs
- MetadataProperty.cs
- VectorAnimationBase.cs
- TypeRestriction.cs
- XmlChildEnumerator.cs
- ConstructorNeedsTagAttribute.cs
- HebrewCalendar.cs
- ScriptResourceInfo.cs
- ToolBarButton.cs
- SQLMembershipProvider.cs
- SafeFileMapViewHandle.cs
- Animatable.cs
- HitTestParameters.cs
- WpfXamlLoader.cs
- ResourceProviderFactory.cs
- ExpressionCopier.cs
- DataStreamFromComStream.cs