示例#1
0
        // Verify and Retrieve the Boolean Attribute.  If it is not
        // a valid value then log an error and set the value to a given default.
        internal void VerifyAndGetBooleanAttribute(
            ExceptionAction action, bool defaultValue, out bool newValue)
        {
            if (Reader.Value == "true")
            {
                newValue = true;
            }
            else
            {
                if (Reader.Value == "false")
                {
                    newValue = false;
                }
                else
                {
                    // Unrecognized value
                    newValue = defaultValue;

                    ConfigurationErrorsException ex = new ConfigurationErrorsException(
                        string.Format(SR.Config_invalid_boolean_attribute, Reader.Name),
                        this);

                    SchemaErrors.AddError(ex, action);
                }
            }
        }
示例#2
0
        internal void AddErrorUnrecognizedElement(ExceptionAction action)
        {
            ConfigurationErrorsException ex = new ConfigurationErrorsException(
                SR.Config_base_unrecognized_element,
                this);

            SchemaErrors.AddError(ex, action);
        }
示例#3
0
        internal void AddErrorReservedAttribute(ExceptionAction action)
        {
            ConfigurationErrorsException ex = new ConfigurationErrorsException(
                string.Format(SR.Config_reserved_attribute, Reader.Name),
                this);

            SchemaErrors.AddError(ex, action);
        }
示例#4
0
        internal void AddErrorRequiredAttribute(string attrib, ExceptionAction action)
        {
            ConfigurationErrorsException ex = new ConfigurationErrorsException(
                SR.Format(SR.Config_missing_required_attribute, attrib, Reader.Name),
                this);

            SchemaErrors.AddError(ex, action);
        }
示例#5
0
        internal void AddErrorUnrecognizedAttribute(ExceptionAction action)
        {
            ConfigurationErrorsException ex = new ConfigurationErrorsException(
                SR.Format(SR.Config_base_unrecognized_attribute, Reader.Name),
                this);

            SchemaErrors.AddError(ex, action);
        }
示例#6
0
        // Add an error if the node type is not permitted by the configuration schema.
        internal void VerifyIgnorableNodeType(ExceptionAction action)
        {
            XmlNodeType nodeType = Reader.NodeType;

            if ((nodeType != XmlNodeType.Comment) && (nodeType != XmlNodeType.EndElement))
            {
                ConfigurationException ex = new ConfigurationErrorsException(
                    SR.Config_base_unrecognized_element,
                    this);

                SchemaErrors.AddError(ex, action);
            }
        }
示例#7
0
        internal void VerifyAndGetNonEmptyStringAttribute(ExceptionAction action, out string newValue)
        {
            if (!string.IsNullOrEmpty(Reader.Value))
            {
                newValue = Reader.Value;
            }
            else
            {
                newValue = null;

                ConfigurationException ex = new ConfigurationErrorsException(
                    string.Format(SR.Empty_attribute, Reader.Name),
                    this);

                SchemaErrors.AddError(ex, action);
            }
        }
示例#8
0
        /// <summary>
        /// Verify and Retrieve the Boolean Attribute.  If it is not
        /// a valid value then log an error and set the value to a given default.
        /// </summary>
        internal void VerifyAndGetBooleanAttribute(
            ExceptionAction action, bool defaultValue, out bool newValue)
        {
            switch (Reader.Value)
            {
            case "true":
                newValue = true;
                break;

            case "false":
                newValue = false;
                break;

            default:
                newValue = defaultValue;
                SchemaErrors.AddError(
                    new ConfigurationErrorsException(string.Format(SR.Config_invalid_boolean_attribute, Reader.Name), this),
                    action);
                break;
            }
        }