Inheritance: BaseConfigurationRecord
示例#1
0
            private void Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
            {
                // Get the type of the factory
                Type type = TypeUtil.GetType(configRecord.Host, factoryRecord.FactoryTypeName,
                                             true);

                // If the type is a ConfigurationSection, that's the type.
                if (typeof(ConfigurationSection).IsAssignableFrom(type))
                {
                    _sectionCtor = TypeUtil.GetConstructor(type, typeof(ConfigurationSection),
                                                           true);
                }
                else
                {
                    // Note: in v1, IConfigurationSectionHandler is in effect a factory that has a Create method
                    // that creates the real section object.

                    // throws if type does not implement IConfigurationSectionHandler
                    TypeUtil.VerifyAssignableType(typeof(IConfigurationSectionHandler), type, true);

                    // Create an instance of the handler
                    _sectionHandler =
                        (IConfigurationSectionHandler)TypeUtil.CreateInstance(type);
                }
            }
示例#2
0
        internal static IInternalConfigRecord Create(InternalConfigRoot configRoot, IInternalConfigRecord parent, string configPath)
        {
            RuntimeConfigurationRecord record = new RuntimeConfigurationRecord();

            record.Init(configRoot, (BaseConfigurationRecord)parent, configPath, null);
            return(record);
        }
示例#3
0
 private object CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
 {
     if (this._sectionCtor != null)
     {
         ConfigurationSection section = (ConfigurationSection)System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(this._sectionCtor);
         section.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord, sectionRecord);
         section.CallInit();
         ConfigurationSection parentElement = (ConfigurationSection)parentConfig;
         section.Reset(parentElement);
         if (reader != null)
         {
             section.DeserializeSection(reader);
         }
         ConfigurationErrorsException errors = section.GetErrors();
         if (errors != null)
         {
             throw errors;
         }
         section.SetReadOnly();
         section.ResetModified();
         return(section);
     }
     if (reader != null)
     {
         XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);
         CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);
         object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);
         return(this._sectionHandler.Create(parentConfig, configContext, xmlNode));
     }
     return(null);
 }
示例#4
0
            internal object CreateSection(bool inputIsTrusted, RuntimeConfigurationRecord configRecord,
                                          FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
            {
                object config;

                if (_sectionCtor != null)
                {
                    ConfigurationSection configSection =
                        (ConfigurationSection)_sectionCtor.Invoke(null);

                    configSection.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord,
                                                                                        sectionRecord);

                    configSection.CallInit();

                    ConfigurationSection parentSection = (ConfigurationSection)parentConfig;
                    configSection.Reset(parentSection);

                    if (reader != null)
                    {
                        configSection.DeserializeSection(reader);
                    }

                    // throw if there are any cached errors
                    ConfigurationErrorsException errors = configSection.GetErrors();
                    if (errors != null)
                    {
                        throw errors;
                    }

                    // don't allow changes to sections at runtime
                    configSection.SetReadOnly();

                    // reset the modified bit
                    configSection.ResetModified();

                    config = configSection;
                }
                else
                {
                    if (reader != null)
                    {
                        XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);

                        CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);

                        // In v1, our old section handler expects a context that contains the virtualPath from the configPath
                        object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);

                        config = _sectionHandler.Create(parentConfig, configContext, xmlNode);
                    }
                    else
                    {
                        config = null;
                    }
                }

                return(config);
            }
示例#5
0
 internal object CreateSection(bool inputIsTrusted, RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
 {
     if (inputIsTrusted)
     {
         return(this.CreateSectionWithFullTrust(configRecord, factoryRecord, sectionRecord, parentConfig, reader));
     }
     return(this.CreateSectionWithRestrictedPermissions(configRecord, factoryRecord, sectionRecord, parentConfig, reader));
 }
        static internal IInternalConfigRecord Create(
                InternalConfigRoot          configRoot,
                IInternalConfigRecord       parent,
                string                      configPath) {

            RuntimeConfigurationRecord configRecord = new RuntimeConfigurationRecord();
            configRecord.Init(configRoot, (BaseConfigurationRecord) parent, configPath, null);
            return configRecord;
        }
示例#7
0
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     if (factoryRecord.IsFromTrustedConfigRecord)
     {
         this.InitWithFullTrust(configRecord, factoryRecord);
     }
     else
     {
         this.InitWithRestrictedPermissions(configRecord, factoryRecord);
     }
 }
示例#8
0
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     // If the factory record was defined in a trusted config record, ignore user code on stack
     if (factoryRecord.IsFromTrustedConfigRecord)
     {
         InitWithFullTrust(configRecord, factoryRecord);
     }
     else
     {
         // Run configuration section handlers as if user code was on the stack
         InitWithRestrictedPermissions(configRecord, factoryRecord);
     }
 }
示例#9
0
            private void Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
            {
                Type c = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(configRecord.Host, factoryRecord.FactoryTypeName, true);

                if (typeof(ConfigurationSection).IsAssignableFrom(c))
                {
                    this._sectionCtor = System.Configuration.TypeUtil.GetConstructorWithReflectionPermission(c, typeof(ConfigurationSection), true);
                }
                else
                {
                    System.Configuration.TypeUtil.VerifyAssignableType(typeof(IConfigurationSectionHandler), c, true);
                    this._sectionHandler = (IConfigurationSectionHandler)System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(c);
                }
            }
示例#10
0
            private void InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
            {
                bool flag = false;

                try
                {
                    PermissionSet restrictedPermissions = configRecord.GetRestrictedPermissions();
                    if (restrictedPermissions != null)
                    {
                        restrictedPermissions.PermitOnly();
                        flag = true;
                    }
                    this.Init(configRecord, factoryRecord);
                }
                finally
                {
                    if (flag)
                    {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
            }
示例#11
0
            private void InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
            {
                // Run configuration section handlers as if user code was on the stack
                bool revertPermitOnly = false;

                try {
                    PermissionSet permissionSet = configRecord.GetRestrictedPermissions();
                    if (permissionSet != null)
                    {
                        permissionSet.PermitOnly();
                        revertPermitOnly = true;
                    }

                    Init(configRecord, factoryRecord);
                }
                finally {
                    if (revertPermitOnly)
                    {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
            }
示例#12
0
            private object CreateSectionWithRestrictedPermissions(
                RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord,
                object parentConfig, ConfigXmlReader reader)
            {
                // run configuration section handlers as if user code was on the stack
                bool revertPermitOnly = false;

                try {
                    PermissionSet permissionSet = configRecord.GetRestrictedPermissions();
                    if (permissionSet != null)
                    {
                        permissionSet.PermitOnly();
                        revertPermitOnly = true;
                    }

                    return(CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader));
                }
                finally {
                    if (revertPermitOnly)
                    {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
            }
示例#13
0
            private object CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
            {
                object obj2;
                bool   flag = false;

                try
                {
                    PermissionSet restrictedPermissions = configRecord.GetRestrictedPermissions();
                    if (restrictedPermissions != null)
                    {
                        restrictedPermissions.PermitOnly();
                        flag = true;
                    }
                    obj2 = this.CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
                }
                finally
                {
                    if (flag)
                    {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
                return(obj2);
            }
 private void InitWithFullTrust(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord) {
     Init(configRecord, factoryRecord);
 }
            private void Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord) {
                // Get the type of the factory
                Type type = TypeUtil.GetTypeWithReflectionPermission(configRecord.Host, factoryRecord.FactoryTypeName, true);

                // If the type is a ConfigurationSection, that's the type.
                if (typeof(ConfigurationSection).IsAssignableFrom(type)) {
                    _sectionCtor = TypeUtil.GetConstructorWithReflectionPermission(type, typeof(ConfigurationSection), true);
                }
                else {
                    // Note: in v1, IConfigurationSectionHandler is in effect a factory that has a Create method
                    // that creates the real section object.

                    // throws if type does not implement IConfigurationSectionHandler
                    TypeUtil.VerifyAssignableType(typeof(IConfigurationSectionHandler), type, true);

                    // Create an instance of the handler
                    _sectionHandler = (IConfigurationSectionHandler) TypeUtil.CreateInstanceWithReflectionPermission(type);
                }
            }
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord) {
     // If the factory record was defined in a trusted config record, ignore user code on stack
     if (factoryRecord.IsFromTrustedConfigRecord) {
         InitWithFullTrust(configRecord, factoryRecord);
     }
     else {
         // Run configuration section handlers as if user code was on the stack
         InitWithRestrictedPermissions(configRecord, factoryRecord);
     }
 }
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     Init(configRecord, factoryRecord);
 }
 private object CreateSectionWithRestrictedPermissions(
         RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, 
         object parentConfig, ConfigXmlReader reader)
 {
     return CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
 }
            private object CreateSectionWithRestrictedPermissions(
                    RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, 
                    object parentConfig, ConfigXmlReader reader) {

                // run configuration section handlers as if user code was on the stack
                bool revertPermitOnly = false;
                try {
                    PermissionSet permissionSet = configRecord.GetRestrictedPermissions();
                    if (permissionSet != null) {
                        permissionSet.PermitOnly();
                        revertPermitOnly = true;
                    }

                    return CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
                }
                finally {
                    if (revertPermitOnly) {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
            }
 private object CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
 {
     object obj2;
     bool flag = false;
     try
     {
         PermissionSet restrictedPermissions = configRecord.GetRestrictedPermissions();
         if (restrictedPermissions != null)
         {
             restrictedPermissions.PermitOnly();
             flag = true;
         }
         obj2 = this.CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
     }
     finally
     {
         if (flag)
         {
             CodeAccessPermission.RevertPermitOnly();
         }
     }
     return obj2;
 }
示例#21
0
 private object CreateSectionWithFullTrust(
     RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord,
     object parentConfig, ConfigXmlReader reader)
 {
     return(CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader));
 }
示例#22
0
 private void InitWithFullTrust(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     Init(configRecord, factoryRecord);
 }
 private void Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     Type c = System.Configuration.TypeUtil.GetTypeWithReflectionPermission(configRecord.Host, factoryRecord.FactoryTypeName, true);
     if (typeof(ConfigurationSection).IsAssignableFrom(c))
     {
         this._sectionCtor = System.Configuration.TypeUtil.GetConstructorWithReflectionPermission(c, typeof(ConfigurationSection), true);
     }
     else
     {
         System.Configuration.TypeUtil.VerifyAssignableType(typeof(IConfigurationSectionHandler), c, true);
         this._sectionHandler = (IConfigurationSectionHandler) System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(c);
     }
 }
 private void InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     Init(configRecord, factoryRecord);
 }
            private void InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord) {
                // Run configuration section handlers as if user code was on the stack
                bool revertPermitOnly = false;
                try {
                    PermissionSet permissionSet = configRecord.GetRestrictedPermissions();
                    if (permissionSet != null) {
                        permissionSet.PermitOnly();
                        revertPermitOnly = true;
                    }

                    Init(configRecord, factoryRecord);
                }
                finally {
                    if (revertPermitOnly) {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                }
            }
 private object CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
 {
     if (this._sectionCtor != null)
     {
         ConfigurationSection section = (ConfigurationSection) System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(this._sectionCtor);
         section.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord, sectionRecord);
         section.CallInit();
         ConfigurationSection parentElement = (ConfigurationSection) parentConfig;
         section.Reset(parentElement);
         if (reader != null)
         {
             section.DeserializeSection(reader);
         }
         ConfigurationErrorsException errors = section.GetErrors();
         if (errors != null)
         {
             throw errors;
         }
         section.SetReadOnly();
         section.ResetModified();
         return section;
     }
     if (reader != null)
     {
         XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);
         CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);
         object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);
         return this._sectionHandler.Create(parentConfig, configContext, xmlNode);
     }
     return null;
 }
            private object CreateSectionImpl(
                    RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, 
                    object parentConfig, ConfigXmlReader reader) {

                object config;

                if (_sectionCtor != null) {
                    ConfigurationSection configSection = (ConfigurationSection) TypeUtil.InvokeCtorWithReflectionPermission(_sectionCtor);

                    configSection.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord, sectionRecord);

                    configSection.CallInit();

                    ConfigurationSection parentSection = (ConfigurationSection) parentConfig;
                    configSection.Reset(parentSection);

                    if (reader != null) {
                        configSection.DeserializeSection(reader);
                    }

                    // throw if there are any cached errors
                    ConfigurationErrorsException errors = configSection.GetErrors();
                    if (errors != null) {
                        throw errors;
                    }

                    // don't allow changes to sections at runtime
                    configSection.SetReadOnly();

                    // reset the modified bit
                    configSection.ResetModified();

                    config = configSection;
                }
                else {
                    if (reader != null) {
                        XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);

                        CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);

                        // In v1, our old section handler expects a context that contains the virtualPath from the configPath
                        object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);

                        config = _sectionHandler.Create(parentConfig, configContext, xmlNode);
                    }
                    else {
                        config = null;
                    }
                }

                return config;
            }
示例#28
0
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     Init(configRecord, factoryRecord);
 }
            private object CreateSectionWithFullTrust(
                    RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, 
                    object parentConfig, ConfigXmlReader reader) {

                return CreateSectionImpl(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
            }
 internal RuntimeConfigurationFactory(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     if (factoryRecord.IsFromTrustedConfigRecord)
     {
         this.InitWithFullTrust(configRecord, factoryRecord);
     }
     else
     {
         this.InitWithRestrictedPermissions(configRecord, factoryRecord);
     }
 }
            internal object CreateSection(bool inputIsTrusted, RuntimeConfigurationRecord configRecord, 
                    FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader) {

                if (inputIsTrusted) {
                    return CreateSectionWithFullTrust(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
                }
                else {
                    return CreateSectionWithRestrictedPermissions(configRecord, factoryRecord, sectionRecord, parentConfig, reader);
                }
            }
 private void InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
 {
     bool flag = false;
     try
     {
         PermissionSet restrictedPermissions = configRecord.GetRestrictedPermissions();
         if (restrictedPermissions != null)
         {
             restrictedPermissions.PermitOnly();
             flag = true;
         }
         this.Init(configRecord, factoryRecord);
     }
     finally
     {
         if (flag)
         {
             CodeAccessPermission.RevertPermitOnly();
         }
     }
 }