Exemple #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public CompositeServiceDirectoryCatalogCollection()
        {
            // Get the current host element.
            CompositeServiceDirectoryCatalogElement host =
                (CompositeServiceDirectoryCatalogElement)CreateNewElement();

            // Add the element to the collection.
            Add(host);
        }
Exemple #2
0
        /// <summary>
        /// Get the composite service.
        /// </summary>
        /// <param name="name">The specific service name to search for the path.</param>
        /// <param name="section">The config section group and section name.</param>
        /// <returns>The service; else null.</returns>
        public CompositeServiceDirectoryCatalogElement GetServiceDirectory(string name, string section = "CompositeGroup/CompositeServices")
        {
            CompositeServiceDirectoryCatalogElement service = 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.
                CompositeServices defaultHost =
                    (CompositeServices)System.Configuration.ConfigurationManager.GetSection(section);

                // Get the list of assembly paths used to load the composite servers.
                CompositeServiceDirectoryCatalogCollection serviceCol = defaultHost.ServiceDirectoryCatalogSection;

                // If a service has not been found.
                if (service == null)
                {
                    if (serviceCol != null)
                    {
                        // For each service found
                        foreach (CompositeServiceDirectoryCatalogElement item in serviceCol)
                        {
                            // If a name has been specified.
                            if (item.Name.ToLower() == name.ToLower())
                            {
                                // Return this service.
                                service = item;
                                break;
                            }
                        }
                    }
                }

                return(service);
            }
            catch (Exception)
            {
                return(null);
            }
        }
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(CompositeServiceDirectoryCatalogElement element)
 {
     // Add the element to the base
     // ConfigurationElementCollection type.
     BaseAdd(element);
 }