Exemplo n.º 1
0
        /// <summary>
        /// Get the reflection provider type.
        /// </summary>
        /// <param name="name">The name of the host.</param>
        /// <param name="section">The config section group and section name.</param>
        /// <returns>The reflection provider type; else null.</returns>
        public string GetReflectionProvider(string name, string section = "NequeoReflectionGroup/NequeoReflections")
        {
            string provider = 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.
                ReflectionsProvider defaultHost =
                    (ReflectionsProvider)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 provider element.
                ReflectionsProviderElement providerElement = defaultHost.HostSection[name];
                provider = providerElement.ProviderType;
            }
            catch (Exception)
            {
                throw;
            }

            // Return the provider type.
            return(provider);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public ReflectionsProviderCollection()
        {
            // Get the current host element.
            ReflectionsProviderElement host =
                (ReflectionsProviderElement)CreateNewElement();

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