MWA and intellisense for configuration sections
public class HttpErrorsCollection : ConfigurationElementCollectionBase<HttpErrorsCollectionElement>
{
}
uint statusCode,
element.StatusCode = statusCode;
return Add(element);
protected override HttpErrorsCollectionElement CreateNewElement(string elementTagName)
public void Remove(uint statusCode, int subStatusCode)
public string PrefixLanguageFilePath
{
get { return (string)base["prefixLanguageFilePath"]; }
set { base["prefixLanguageFilePath"] = (string)value; }
}
public string Path
{
get { return (string)base["path"]; }
set { base["path"] = (string)value; }
}
public EnumHttpErrorsResponseMode ResponseMode
{
get { return (EnumHttpErrorsResponseMode)base["responseMode"]; }
set { base["responseMode"] = (int)value; }
}
public enum EnumHttpErrorsErrorMode
{
DetailedLocalOnly = 0,
Custom = 1,
Detailed = 2
}
public class HttpErrorsSection : ConfigurationSection
{
public static string SectionName = "system.webServer/httpErrors";
public HttpErrorsCollection Errors
{
get { return (HttpErrorsCollection)GetCollection("error", typeof(HttpErrorsCollection)); }
}
}
If the section/element schema has an <element> tag, you can define a type deriving from ConfigurationElement and then pass the type in GetChildElement. Taking example of request filtering section, code to handle requestLimits element will look like this.
public static string SectionName = "system.webServer/security/requestFiltering";
public RequestLimitsElement RequestLimits
{
get { return (RequestLimitsElement)GetChildElement("requestLimits", typeof(RequestLimitsElement)); }
}
}
Declaration of RequestLimitsElement looks similar to collection element class as in HttpErrorsCollectionElement.
public class RequestLimitsElement : ConfigurationElement
set { base["maxQueryString"] = (uint)value; }
//
// HeaderLimitsCollection will look similar to
}
Checkout the tool to generate this code from schema definition here.
View the original post