// 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); } } }
internal void AddErrorUnrecognizedElement(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.Config_base_unrecognized_element, this); SchemaErrors.AddError(ex, action); }
internal void AddErrorReservedAttribute(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( string.Format(SR.Config_reserved_attribute, Reader.Name), this); SchemaErrors.AddError(ex, action); }
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); }
internal void AddErrorUnrecognizedAttribute(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.Format(SR.Config_base_unrecognized_attribute, Reader.Name), this); SchemaErrors.AddError(ex, action); }
// 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); } }
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); } }
/// <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; } }