Пример #1
0
        /// <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;
        }
Пример #2
0
 /// <summary>
 /// Initializes the <see cref="ApiUrl"/> class.
 /// </summary>
 static ApiUrl()
 {
     Config = ConfigurationManager.GetSection("ApiUrl") as ApiUrl;
 }