Example #1
0
        /// <summary>
        /// Gets the remote host elements.
        /// </summary>
        /// <param name="section">The config section group and section name.</param>
        /// <returns>The remote host element; else null.</returns>
        public RemoteHostElement[] RemoteHostElements(string section = "NequeoServerGroup/NequeoRemoteHosts")
        {
            RemoteHostElement[] serverHostElements = null;

            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.
                RemoteHosts defaultHost =
                    (RemoteHosts)System.Configuration.ConfigurationManager.GetSection(section);

                // Make sure the section is defined.
                if (defaultHost == null)
                {
                    throw new Exception("Configuration section has not been defined.");
                }

                // Return the collection.
                RemoteHostElement[] items = new RemoteHostElement[defaultHost.HostSection.Count];
                defaultHost.HostSection.CopyTo(items, 0);
                serverHostElements = items.Where(q => (q.Name != "localhost")).ToArray();
            }
            catch (Exception)
            {
                throw;
            }

            // Return the host elements.
            return(serverHostElements);
        }
Example #2
0
        /// <summary>
        /// Get the remote host element.
        /// </summary>
        /// <param name="name">The name of the host.</param>
        /// <param name="section">The config section group and section name.</param>
        /// <returns>The remote host element; else null.</returns>
        public RemoteHostElement GetRemoteHost(string name, string section = "NequeoServerGroup/NequeoRemoteHosts")
        {
            RemoteHostElement serverHostElement = null;

            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.
                RemoteHosts defaultHost =
                    (RemoteHosts)System.Configuration.ConfigurationManager.GetSection(section);

                // Make sure the section is defined.
                if (defaultHost == null)
                {
                    throw new Exception("Configuration section has not been defined.");
                }

                // Get the host element.
                serverHostElement = defaultHost.HostSection[name];
            }
            catch (Exception)
            {
                throw;
            }

            // Return the host element.
            return(serverHostElement);
        }
Example #3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public RemoteHostCollection()
        {
            // Get the current host element.
            RemoteHostElement host =
                (RemoteHostElement)CreateNewElement();

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