/// <summary> /// Creates a configuration section handler. /// </summary> /// <param name="parent">Parent object.</param> /// <param name="configContext">Configuration context object.</param> /// <param name="section">Section XML node.</param> /// <returns>The created section handler object.</returns> public object Create(object parent, object configContext, XmlNode section) { var config = new ApiUrl(); var info = typeof (ApiUrl).GetProperties(); foreach (var fileinfo in info) { var dynamicDiscoveryNode = section.SelectSingleNode(fileinfo.Name); if (dynamicDiscoveryNode != null && dynamicDiscoveryNode.Attributes != null) { var attribute = dynamicDiscoveryNode.Attributes["Value"]; if (attribute != null) fileinfo.SetValue(config, attribute.Value, null); } } return config; }
/// <summary> /// Initializes the <see cref="ApiUrl"/> class. /// </summary> static ApiUrl() { Config = ConfigurationManager.GetSection("ApiUrl") as ApiUrl; }