Microsoft.Web.Administration.ConfigurationElement.Validate C# (CSharp) Method

Validate() private method

private Validate ( bool loading ) : void
loading bool
return void
        internal void Validate(bool loading)
        {
            foreach (ConfigurationAttributeSchema attribute in this.Schema.AttributeSchemas)
            {
                if (!attribute.IsRequired)
                {
                    continue;
                }

                if (!this.RawAttributes.ContainsKey(attribute.Name))
                {
                    if (loading)
                    {
                        var line = (this.Entity as IXmlLineInfo).LineNumber;
                        var error = string.Format("Missing required attribute '{0}'", attribute.Name);
                        throw new COMException(
                            string.Format("Line number: {0}\r\nError: {1}\r\n", line, error));
                    }

                    throw new FileNotFoundException(
                        string.Format(
                            "Filename: \r\nError: Element is missing required attributes {0}\r\n\r\n",
                            attribute.Name));
                }
            }
        }