コード例 #1
0
 internal static ConfigurationErrorsException WrapAsConfigException(string outerMessage, Exception e,
                                                                    IConfigErrorInfo errorInfo)
 {
     return(errorInfo != null
         ? WrapAsConfigException(outerMessage, e, errorInfo.Filename, errorInfo.LineNumber)
         : WrapAsConfigException(outerMessage, e, null, 0));
 }
コード例 #2
0
ファイル: ExceptionUtil.cs プロジェクト: chcosta/corefx
 internal static ConfigurationErrorsException WrapAsConfigException(string outerMessage, Exception e,
     IConfigErrorInfo errorInfo)
 {
     return errorInfo != null
         ? WrapAsConfigException(outerMessage, e, errorInfo.Filename, errorInfo.LineNumber)
         : WrapAsConfigException(outerMessage, e, null, 0);
 }
コード例 #3
0
 private static string GetUnsafeConfigErrorInfoFilename(IConfigErrorInfo errorInfo)
 {
     if (errorInfo != null)
     {
         return(errorInfo.Filename);
     }
     return(null);
 }
コード例 #4
0
 static internal ConfigurationErrorsException WrapAsConfigException(string outerMessage, Exception e, IConfigErrorInfo errorInfo) {
     if (errorInfo != null) {
         return WrapAsConfigException(outerMessage, e, errorInfo.Filename, errorInfo.LineNumber);
     }
     else {
         return WrapAsConfigException(outerMessage, e, null, 0);
     }
 }
コード例 #5
0
 private static int GetConfigErrorInfoLineNumber(IConfigErrorInfo errorInfo)
 {
     if (errorInfo != null)
     {
         return(errorInfo.LineNumber);
     }
     return(0);
 }
コード例 #6
0
        /// <inheritdoc />
        protected override void DeserializeSection(XmlReader reader)
        {
            // Grab file path
            IConfigErrorInfo errorInfo = reader as IConfigErrorInfo;

            FilePath = errorInfo != null ? errorInfo.Filename : CurrentConfiguration?.FilePath;

            base.DeserializeSection(reader);
        }
コード例 #7
0
 public virtual void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition,
                                             ConfigurationAllowExeDefinition allowExeDefinition,
                                             IConfigErrorInfo errorInfo)
 {
     if (!IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
     {
         throw new ConfigurationErrorsException("The section can't be defined in this file (the allowed definition context is '" + allowDefinition + "').", errorInfo.Filename, errorInfo.LineNumber);
     }
 }
コード例 #8
0
        private int GetLineNumber(XmlReader reader)
        {
            IConfigErrorInfo err = reader as IConfigErrorInfo;

            if (err != null)
            {
                return((int)err.LineNumber);
            }
            return(0);
        }
コード例 #9
0
        public static int GetXmlNodeLineNumber(XmlNode node)
        {
            IConfigErrorInfo info = node as IConfigErrorInfo;

            if (info != null)
            {
                return(info.LineNumber);
            }
            return(0);
        }
コード例 #10
0
        public static int GetXmlNodeLineNumber(XmlNode node)
        {
            IConfigErrorInfo configNode = node as IConfigErrorInfo;

            if (configNode != null)
            {
                return(configNode.LineNumber);
            }
            return(0);
        }
コード例 #11
0
        private static string GetUnsafeXmlNodeFilename(XmlNode node)
        {
            IConfigErrorInfo info = node as IConfigErrorInfo;

            if (info != null)
            {
                return(info.Filename);
            }
            return(string.Empty);
        }
コード例 #12
0
        private int GetLineNumber(XmlReader reader)
        {
            IConfigErrorInfo info = reader as IConfigErrorInfo;

            if (info != null)
            {
                return(info.LineNumber);
            }
            return(0);
        }
コード例 #13
0
        private string GetFilename(XmlReader reader)
        {
            IConfigErrorInfo info = reader as IConfigErrorInfo;

            if (info != null)
            {
                return(info.Filename);
            }
            return("");
        }
コード例 #14
0
        private string GetFilename(XmlReader reader)
        {
            IConfigErrorInfo err = reader as IConfigErrorInfo;

            if (err != null)
            {
                return((string)err.Filename);
            }

            return("");
        }
コード例 #15
0
        private static string GetUnsafeXmlNodeFilename(XmlNode node)
        {
            IConfigErrorInfo configNode = node as IConfigErrorInfo;

            if (configNode != null)
            {
                return(configNode.Filename);
            }

            return(string.Empty);
        }
コード例 #16
0
    public object Create(object parent, object configContext, XmlNode section)
    {
        object  result        = parent;
        XmlNode fileAttribute = section.Attributes.RemoveNamedItem("file");

        if (fileAttribute == null && fileAttribute.Value.Length == 0)
        {
            return(new NameValueSectionHandler().Create(result, null, section));
        }
        IConfigErrorInfo configXmlNode = fileAttribute as IConfigErrorInfo;

        if (configXmlNode == null)
        {
            return(null);
        }

        string directory        = Path.GetDirectoryName(configXmlNode.Filename);
        string absoluteFilePath = Path.GetFullPath(directory + fileAttribute.Value);

        if (!File.Exists(absoluteFilePath))
        {
            throw new ConfigurationErrorsException(string.Format("external config file: {0} does not exists", absoluteFilePath));
        }
        var configXmlDocument = new ConfigXmlDocument();

        try
        {
            configXmlDocument.Load(absoluteFilePath);
        }
        catch (XmlException e)
        {
            throw new ConfigurationErrorsException(e.Message, e, absoluteFilePath, e.LineNumber);
        }
        if (section.Name != configXmlDocument.DocumentElement.Name)
        {
            throw new ConfigurationErrorsException(string.Format("Section name '{0}' in app.config does not match section name '{1}' in file '{2}'", section.Name, configXmlDocument.DocumentElement.Name, absoluteFilePath));
        }

        var nodeToDecrypt = configXmlDocument.DocumentElement["EncryptedData"];

        if (nodeToDecrypt == null)
        {
            throw new ConfigurationErrorsException(string.Format("External encrypted file {0} does not contain EncryptedData element", absoluteFilePath));
        }
        var protectionProvider     = new DpapiProtectedConfigurationProvider();
        var decryptedConfigSection = protectionProvider.Decrypt(nodeToDecrypt);

        result = new NameValueSectionHandler().Create(result, null, decryptedConfigSection);

        return(result);
    }
        public object Create(object parent, object configContext, XmlNode section)
        {
            object result = parent;

            // parse XML
            XmlNode fileAttribute = section.Attributes.RemoveNamedItem("file");

            result = NameValueSectionHandler.CreateStatic(result, section);

            if (fileAttribute != null && fileAttribute.Value.Length != 0)
            {
                string filename = null;
                filename = fileAttribute.Value;
                IConfigErrorInfo configXmlNode = fileAttribute as IConfigErrorInfo;
                if (configXmlNode == null)
                {
                    return(null);
                }

                string configFile         = configXmlNode.Filename;
                string directory          = Path.GetDirectoryName(configFile);
                string sourceFileFullPath = Path.Combine(directory, filename);

                if (File.Exists(sourceFileFullPath))
                {
                    ConfigXmlDocument doc = new ConfigXmlDocument();
                    try
                    {
                        doc.Load(sourceFileFullPath);
                    }
                    catch (XmlException e)
                    {
                        throw new ConfigurationErrorsException(e.Message, e, sourceFileFullPath, e.LineNumber);
                    }

                    if (section.Name != doc.DocumentElement.Name)
                    {
                        throw new ConfigurationErrorsException(
                                  SR.Format(SR.Config_name_value_file_section_file_invalid_root, section.Name),
                                  doc.DocumentElement);
                    }

                    result = NameValueSectionHandler.CreateStatic(result, doc.DocumentElement);
                }
            }

            return(result);
        }
コード例 #18
0
        private void LoadFromConfigXmlReader(ConfigXmlReader reader)
        {
            IConfigErrorInfo err = (IConfigErrorInfo)reader;

            _filename   = err.Filename;
            _lineOffset = err.LineNumber + 1;

            try {
                _reader = reader;
                base.Load(_reader);
            }
            finally {
                if (_reader != null)
                {
                    _reader.Close();
                    _reader = null;
                }
            }
        }
コード例 #19
0
        private void LoadFromConfigXmlReader(ConfigXmlReader reader)
        {
            IConfigErrorInfo info = reader;

            this._filename   = info.Filename;
            this._lineOffset = info.LineNumber + 1;
            try
            {
                this._reader = reader;
                base.Load(this._reader);
            }
            finally
            {
                if (this._reader != null)
                {
                    this._reader.Close();
                    this._reader = null;
                }
            }
        }
コード例 #20
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            object  obj2 = parent;
            XmlNode node = section.Attributes.RemoveNamedItem("file");

            obj2 = NameValueSectionHandler.CreateStatic(obj2, section);
            if ((node == null) || (node.Value.Length == 0))
            {
                return(obj2);
            }
            string str = null;

            str = node.Value;
            IConfigErrorInfo info = node as IConfigErrorInfo;

            if (info == null)
            {
                return(null);
            }
            string path = Path.Combine(Path.GetDirectoryName(info.Filename), str);

            if (!File.Exists(path))
            {
                return(obj2);
            }
            ConfigXmlDocument document = new ConfigXmlDocument();

            try
            {
                document.Load(path);
            }
            catch (XmlException exception)
            {
                throw new ConfigurationErrorsException(exception.Message, exception, path, exception.LineNumber);
            }
            if (section.Name != document.DocumentElement.Name)
            {
                throw new ConfigurationErrorsException(System.SR.GetString("Config_name_value_file_section_file_invalid_root", new object[] { section.Name }), document.DocumentElement);
            }
            return(NameValueSectionHandler.CreateStatic(obj2, document.DocumentElement));
        }
コード例 #21
0
 public virtual void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     host.VerifyDefinitionAllowed(configPath, allowDefinition, allowExeDefinition, errorInfo);
 }
コード例 #22
0
        private int GetLineNumber(XmlReader reader)
        {
            IConfigErrorInfo err = reader as IConfigErrorInfo;

            return(err?.LineNumber ?? 0);
        }
コード例 #23
0
        public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
        {
            if (!IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
            {
                switch (allowExeDefinition)
                {
                    case ConfigurationAllowExeDefinition.MachineOnly:
                        throw new ConfigurationErrorsException(
                            SR.GetString(SR.Config_allow_exedefinition_error_machine), errorInfo);

                    case ConfigurationAllowExeDefinition.MachineToApplication:
                        throw new ConfigurationErrorsException(
                            SR.GetString(SR.Config_allow_exedefinition_error_application), errorInfo);

                    case ConfigurationAllowExeDefinition.MachineToRoamingUser:
                        throw new ConfigurationErrorsException(
                            SR.GetString(SR.Config_allow_exedefinition_error_roaminguser), errorInfo);

                    default:
                        // If we have extended ConfigurationAllowExeDefinition
                        // make sure to update this switch accordingly
                        throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::VerifyDefinitionAllowed");
                }
            }
        }
 public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     if (!this.IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
     {
         ConfigurationAllowExeDefinition definition = allowExeDefinition;
         if (definition != ConfigurationAllowExeDefinition.MachineOnly)
         {
             if (definition == ConfigurationAllowExeDefinition.MachineToApplication)
             {
                 throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_application"), errorInfo);
             }
             if (definition == ConfigurationAllowExeDefinition.MachineToRoamingUser)
             {
                 throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_roaminguser"), errorInfo);
             }
             throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::VerifyDefinitionAllowed");
         }
         throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_machine"), errorInfo);
     }
 }
コード例 #25
0
 // Get file and linenumber from an IConfigErrorInfo
 private static int GetConfigErrorInfoLineNumber(IConfigErrorInfo errorInfo)
 {
     return(errorInfo?.LineNumber ?? 0);
 }
コード例 #26
0
 internal ConfigurationErrorsException(string message, Exception inner, IConfigErrorInfo errorInfo) :
     this(message, inner, GetConfigErrorInfoFilename(errorInfo), GetConfigErrorInfoLineNumber(errorInfo))
 {
 }
コード例 #27
0
        static internal string NormalizeConfigSource(string configSource, IConfigErrorInfo errorInfo) {
            if (String.IsNullOrEmpty(configSource)) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_source_invalid_format), errorInfo);
            }

            string trimmedConfigSource = configSource.Trim();
            if (trimmedConfigSource.Length != configSource.Length) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_source_invalid_format), errorInfo);
            }

            if (configSource.IndexOf('/') != -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_source_invalid_chars), errorInfo);
            }
            
            if (String.IsNullOrEmpty(configSource) || System.IO.Path.IsPathRooted(configSource)) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_source_invalid_format), errorInfo);
            }

            return configSource;
        }
コード例 #28
0
        protected void ValidateUniqueChildConfigSource(
                string configKey, string configSourceStreamName, string configSourceArg, IConfigErrorInfo errorInfo) {

            //
            // Detect if a parent config file is using the same config source stream.
            //
            BaseConfigurationRecord current;
            if (IsLocationConfig) {
                current = _parent._parent;
            }
            else {
                current = _parent;
            }

            while (!current.IsRootConfig) {
                lock (current) {
                    if (current.ConfigStreamInfo.HasStreamInfos) {
                        StreamInfo streamInfo = (StreamInfo) current.ConfigStreamInfo.StreamInfos[configSourceStreamName];
                        if (streamInfo != null) {
                            throw new ConfigurationErrorsException(
                                SR.GetString(SR.Config_source_parent_conflict, configSourceArg),
                                errorInfo);
                        }
                    }
                }

                current = current.Parent;
            }
        }
コード例 #29
0
 private static string GetConfigErrorInfoFilename(IConfigErrorInfo errorInfo)
 {
     return errorInfo?.Filename;
 }
コード例 #30
0
 // Get file and linenumber from an IConfigErrorInfo
 private static int GetConfigErrorInfoLineNumber(IConfigErrorInfo errorInfo)
 {
     return errorInfo?.LineNumber ?? 0;
 }
コード例 #31
0
 internal ConfigurationErrorsException(string message, Exception inner, IConfigErrorInfo errorInfo) :
     this(message, inner, GetConfigErrorInfoFilename(errorInfo), GetConfigErrorInfoLineNumber(errorInfo))
 { }
 public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     if (!this.IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
     {
         ConfigurationAllowDefinition definition = allowDefinition;
         if (definition != ConfigurationAllowDefinition.MachineOnly)
         {
             if (definition == ConfigurationAllowDefinition.MachineToWebRoot)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_allow_definition_error_webroot"), errorInfo.Filename, errorInfo.LineNumber);
             }
             if (definition == ConfigurationAllowDefinition.MachineToApplication)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_allow_definition_error_application"), errorInfo.Filename, errorInfo.LineNumber);
             }
             throw System.Web.Util.ExceptionUtil.UnexpectedError("WebConfigurationHost::VerifyDefinitionAllowed");
         }
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_allow_definition_error_machine"), errorInfo.Filename, errorInfo.LineNumber);
     }
 }
コード例 #33
0
        static internal string ValidateProtectionProviderAttribute(string protectionProvider, IConfigErrorInfo errorInfo) {
            if (String.IsNullOrEmpty(protectionProvider)) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Protection_provider_invalid_format), errorInfo);
            }

            return protectionProvider;
        }
 private static int GetConfigErrorInfoLineNumber(IConfigErrorInfo errorInfo)
 {
     if (errorInfo != null)
     {
         return errorInfo.LineNumber;
     }
     return 0;
 }
コード例 #35
0
        // Return null if the subPath represents the current directory, for example:
        //      path=""
        //      path="   "
        //      path="."
        //      path="./"
        internal static string NormalizeLocationSubPath(string subPath, IConfigErrorInfo errorInfo) {
            // if subPath is null or empty, it is the current dir
            if (String.IsNullOrEmpty(subPath))
                return null;

            // if subPath=".", it is the current dir
            if (subPath == ".")
                return null;

            // do not allow whitespace in front of subPath, as the OS
            // handles beginning and trailing whitespace inconsistently
            string trimmedSubPath = subPath.TrimStart();
            if (trimmedSubPath.Length != subPath.Length) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_location_path_invalid_first_character), errorInfo);
            }

            // do not allow problematic starting characters
            if (invalidFirstSubPathCharacters.IndexOf(subPath[0]) != -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_location_path_invalid_first_character), errorInfo);
            }

            // do not allow whitespace at end of subPath, as the OS
            // handles beginning and trailing whitespace inconsistently
            trimmedSubPath = subPath.TrimEnd();
            if (trimmedSubPath.Length != subPath.Length) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_location_path_invalid_last_character), errorInfo);
            }

            // the file system ignores trailing '.', '\', or '/', so do not allow it in a location subpath specification
            if (invalidLastSubPathCharacters.IndexOf(subPath[subPath.Length-1]) != -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_location_path_invalid_last_character), errorInfo);
            }

            // combination of URI reserved characters and OS invalid filename characters, minus / (allowed reserved character)
            if (subPath.IndexOfAny(s_invalidSubPathCharactersArray) != -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_location_path_invalid_character), errorInfo);
            }

            return subPath;
        }
 internal ConfigurationErrorsException(string message, IConfigErrorInfo errorInfo) : this(message, null, GetUnsafeConfigErrorInfoFilename(errorInfo), GetConfigErrorInfoLineNumber(errorInfo))
 {
 }
コード例 #37
0
        // Check if the section name contains reserved words from the config system,
        // and is a valid name for an XML Element.
        static protected void VerifySectionName(string name, IConfigErrorInfo errorInfo, bool allowImplicit) {
            if (String.IsNullOrEmpty(name)) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_tag_name_invalid), errorInfo);
            }

            // must be a valid name in xml, so that it can be used as an element
            // n.b. - it also excludes forward slash '/'
            try {
                XmlConvert.VerifyName(name);
            }
            // Do not let the exception propagate as an XML exception,
            // for we want errors in the section name to be treated as local errors,
            // not global ones.
            catch (Exception e) {
                throw ExceptionUtil.WrapAsConfigException(SR.GetString(SR.Config_tag_name_invalid), e, errorInfo);
            }
            catch {
                throw ExceptionUtil.WrapAsConfigException(SR.GetString(SR.Config_tag_name_invalid), null, errorInfo);
            }

            if (IsImplicitSection(name)) {
                if (allowImplicit) {
                    // avoid test below for strings starting with "config"
                    return;
                }
                else {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Cannot_declare_or_remove_implicit_section, name), errorInfo);
                }
            }

            if (StringUtil.StartsWith(name, "config")) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_tag_name_cannot_begin_with_config), errorInfo);
            }

            if (name == KEYWORD_LOCATION) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_tag_name_cannot_be_location), errorInfo);
            }
        }
コード例 #38
0
	public virtual void VerifyDefinitionAllowed(string configPath, System.Configuration.ConfigurationAllowDefinition allowDefinition, System.Configuration.ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo) {}
コード例 #39
0
 // VerifyDefinitionAllowed
 //
 // Verify that the Definition is allowed at this 
 // place.
 //
 // For example, if this config record is an application then 
 // make sure the section say's it can be defined in an
 // application
 //
 private void VerifyDefinitionAllowed(FactoryRecord factoryRecord, string configPath, IConfigErrorInfo errorInfo) {
     Host.VerifyDefinitionAllowed(configPath, factoryRecord.AllowDefinition, factoryRecord.AllowExeDefinition, errorInfo);
 }
コード例 #40
0
 private static string GetConfigErrorInfoFilename(IConfigErrorInfo errorInfo)
 {
     return(errorInfo?.Filename);
 }
コード例 #41
0
 // VerifySectionUnlocked
 //
 // Verify the section we have defined is unlocked
 //
 protected void VerifySectionUnlocked(string configKey, IConfigErrorInfo configErrorInfo) {
     if (IsSectionLocked(configKey)) {
         throw new ConfigurationErrorsException(SR.GetString(SR.Config_section_locked), configErrorInfo);
     }
 }
コード例 #42
0
ファイル: TypeUtilTests.cs プロジェクト: kouvel/corefx
 void IInternalConfigHost.VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     throw new NotImplementedException();
 }
 // Normalize a locationSubpath argument
 string IInternalConfigConfigurationFactory.NormalizeLocationSubPath(string subPath, IConfigErrorInfo errorInfo) {
     return BaseConfigurationRecord.NormalizeLocationSubPath(subPath, errorInfo);
 }
コード例 #44
0
        public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition,
                                                     ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
        {
            if (!IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
            {
                switch (allowExeDefinition)
                {
                case ConfigurationAllowExeDefinition.MachineOnly:
                    throw new ConfigurationErrorsException(
                              SR.Config_allow_exedefinition_error_machine, errorInfo);

                case ConfigurationAllowExeDefinition.MachineToApplication:
                    throw new ConfigurationErrorsException(
                              SR.Config_allow_exedefinition_error_application, errorInfo);

                case ConfigurationAllowExeDefinition.MachineToRoamingUser:
                    throw new ConfigurationErrorsException(
                              SR.Config_allow_exedefinition_error_roaminguser, errorInfo);

                default:
                    // If we have extended ConfigurationAllowExeDefinition
                    // make sure to update this switch accordingly
                    throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::VerifyDefinitionAllowed");
                }
            }
        }
コード例 #45
0
 void IInternalConfigHost.VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo) {
 }
コード例 #46
0
 void IInternalConfigHost.VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition,
                                                  ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
 }
コード例 #47
0
 public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     if (!this.IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition))
     {
         ConfigurationAllowExeDefinition definition = allowExeDefinition;
         if (definition != ConfigurationAllowExeDefinition.MachineOnly)
         {
             if (definition == ConfigurationAllowExeDefinition.MachineToApplication)
             {
                 throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_application"), errorInfo);
             }
             if (definition == ConfigurationAllowExeDefinition.MachineToRoamingUser)
             {
                 throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_roaminguser"), errorInfo);
             }
             throw ExceptionUtil.UnexpectedError("ClientConfigurationHost::VerifyDefinitionAllowed");
         }
         throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_allow_exedefinition_error_machine"), errorInfo);
     }
 }
コード例 #48
0
        private string GetFilename(XmlReader reader)
        {
            IConfigErrorInfo err = reader as IConfigErrorInfo;

            return(err != null ? err.Filename : "");
        }
コード例 #49
0
        public override void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo) {
            if (!IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition)) {
                switch (allowDefinition) {
                    case ConfigurationAllowDefinition.MachineOnly:
                        throw new ConfigurationErrorsException(SR.GetString(SR.Config_allow_definition_error_machine), errorInfo.Filename, errorInfo.LineNumber);

                    case ConfigurationAllowDefinition.MachineToWebRoot:
                        throw new ConfigurationErrorsException(SR.GetString(SR.Config_allow_definition_error_webroot), errorInfo.Filename, errorInfo.LineNumber);

                    case ConfigurationAllowDefinition.MachineToApplication:
                        throw new ConfigurationErrorsException(SR.GetString(SR.Config_allow_definition_error_application), errorInfo.Filename, errorInfo.LineNumber);

                    default:
                        // If we have extended ConfigurationAllowDefinition
                        // make sure to update this switch accordingly
                        throw ExceptionUtil.UnexpectedError("WebConfigurationHost::VerifyDefinitionAllowed");
                }
            }
        }
コード例 #50
0
 string IInternalConfigConfigurationFactory.NormalizeLocationSubPath(string subPath, IConfigErrorInfo errorInfo)
 {
     return BaseConfigurationRecord.NormalizeLocationSubPath(subPath, errorInfo);
 }
コード例 #51
0
 public string NormalizeLocationSubPath(string subPath, IConfigErrorInfo errorInfo)
 {
     return(subPath);
 }
 private static string GetUnsafeConfigErrorInfoFilename(IConfigErrorInfo errorInfo)
 {
     if (errorInfo != null)
     {
         return errorInfo.Filename;
     }
     return null;
 }
コード例 #53
0
 public virtual void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo) {
     Host.VerifyDefinitionAllowed(configPath, allowDefinition, allowExeDefinition, errorInfo);
 }
コード例 #54
0
		public virtual void VerifyDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
		{
			if (!IsDefinitionAllowed (configPath, allowDefinition, allowExeDefinition))
				throw new ConfigurationErrorsException ("The section can't be defined in this file (the allowed definition context is '" + allowDefinition + "').", errorInfo.Filename, errorInfo.LineNumber);
		}
コード例 #55
0
        //
        //
        private void ValidateUniqueConfigSource(
                string configKey, string configSourceStreamName, string configSourceArg, IConfigErrorInfo errorInfo) {

            //
            // Detect if another section in this file is using the same configSource 
            // with has a different section name.
            //
            lock (this) {
                if (ConfigStreamInfo.HasStreamInfos) {
                    StreamInfo streamInfo = (StreamInfo) ConfigStreamInfo.StreamInfos[configSourceStreamName];
                    if (streamInfo != null && streamInfo.SectionName != configKey) {
                        throw new ConfigurationErrorsException(
                            SR.GetString(SR.Config_source_cannot_be_shared, configSourceArg),
                            errorInfo);
                    }
                }
            }
            
            ValidateUniqueChildConfigSource(configKey, configSourceStreamName, configSourceArg, errorInfo);
        }
コード例 #56
0
 void IInternalConfigHost.VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
 {
     throw new NotImplementedException();
 }
コード例 #57
0
		public string NormalizeLocationSubPath (string subPath, IConfigErrorInfo errorInfo)
		{
			return subPath;
		}