Exemple #1
0
        /// <summary>
        /// Gets, the http host collection elements.
        /// </summary>
        /// <param name="section">The config section group and section name.</param>
        /// <returns>The http host collection; else null.</returns>
        public static HttpHostElement[] HttpHostElements(string section = "HttpServerGroup/HttpServerHosts")
        {
            try
            {
                // Refreshes the named section so the next time that it is retrieved it will be re-read from disk.
                System.Configuration.ConfigurationManager.RefreshSection(section);

                // Create a new default host type
                // an load the values from the configuration
                // file into the default host type.
                HttpServerHosts baseHandler =
                    (HttpServerHosts)System.Configuration.ConfigurationManager.GetSection(section);

                // Return the element.
                // Return the collection.
                HttpHostElement[] items = new HttpHostElement[baseHandler.HostSection.Count];
                baseHandler.HostSection.CopyTo(items, 0);
                return(items.Where(q => (q.NameAttribute != "default")).ToArray());
            }
            catch (Exception ex)
            {
                // Log the error.
                LogHandler.WriteTypeMessage(
                    ex.Message,
                    MethodInfo.GetCurrentMethod(),
                    Nequeo.Net.Common.Helper.EventApplicationName);

                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public HttpHostCollection()
        {
            // Get the current host element.
            HttpHostElement host =
                (HttpHostElement)CreateNewElement();

            // Add the element to the collection.
            Add(host);
        }
Exemple #3
0
 /// <summary>
 /// Add a new host element type to the collection.
 /// </summary>
 /// <param name="element">The current host element.</param>
 public void Add(HttpHostElement element)
 {
     // Add the element to the base
     // ConfigurationElementCollection type.
     BaseAdd(element);
 }