/// <summary>
        /// This method is called by <see cref="ConfigurationManager.GetSection(string)"/>
        /// for a section defined in the "configSections" section of the .config file with
        /// a "type" attribute specifying this class type (<see cref="ConfigurationSectionListDeserializer"/>).
        /// </summary>
        /// <remarks>
        /// When the static <see cref="Load{T}(string, bool, bool)"/> method of this class calls
        /// <see cref="ConfigurationSectionDeserializerHelper.GetSection(string, bool)"/>,
        /// and it calls <see cref="ConfigurationManager.GetSection(string)"/>, a new instance of this
        /// class is created (because of the "configSections" type specification), and this method is called.
        /// </remarks>
        /// <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>
        object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
        {
            string  sectionTypeName = ConfigurationSectionDeserializerHelper.GetSectionTypeName(section);
            XmlNode arrayNode       = GetArrayNode(section, sectionTypeName);
            string  typeName        = $"System.Collections.Generic.List`1[[{sectionTypeName}]]";

            return(ConfigurationSectionDeserializerHelper.DeserializeXmlNode(
                       caller: this,
                       sectionName: section.Name,
                       node: arrayNode,
                       typeName: typeName,
                       shouldNodeNameMatchTypeName: false));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// This method is called by <see cref="ConfigurationManager.GetSection(string)"/>
 /// for a section defined in the "configSections" section of the .config file with
 /// a "type" attribute specifying this class type (<see cref="ConfigurationSectionDeserializer"/>).
 /// </summary>
 /// <remarks>
 /// When the static <see cref="Load{T}(string, bool)"/> method of this class calls
 /// <see cref="ConfigurationSectionDeserializerHelper.GetSection(string, bool)"/>,
 /// and it calls <see cref="ConfigurationManager.GetSection(string)"/>, a new instance of this
 /// class is created (because of the "configSections" type specification), and this method is called.
 /// </remarks>
 /// <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>
 object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section) =>
 ConfigurationSectionDeserializerHelper.DeserializeXmlNode(
     caller: this,
     sectionName: section.Name,
     node: section,
     typeName: ConfigurationSectionDeserializerHelper.GetSectionTypeName(section));