Beispiel #1
0
        /// <summary>
        ///		Creates a new configuration handler and adds the specified configuration object to the collection.
        /// </summary>
        /// <param name="parent">Composed from the configuration settings in a corresponding parent configuration section.</param>
        /// <param name="context">Provides access to the virtual path for which the configuration section handler computes configuration values. Normally this parameter is reserved and is null.</param>
        /// <param name="section">The XML node that contains the configuration information to be handled. section provides direct access to the XML contents of the configuration section.</param>
        /// <returns></returns>
        public object Create(object parent, object context, XmlNode section)
        {
#if (XML_DEP)
            return(ConfigHelper.GetNameValueCollection(parent as NameValueCollection, section,
                                                       KeyAttributeName, ValueAttributeName));
#else
            return(null);
#endif
        }
        public object Create(object parent, object configContext, XmlNode section)
        {
#if (XML_DEP)
            XmlNode file = null;
            if (section.Attributes != null)
            {
                file = section.Attributes.RemoveNamedItem("file");
            }

            NameValueCollection pairs = ConfigHelper.GetNameValueCollection(
                parent as NameValueCollection,
                section,
                "key",
                "value");

            if (file != null && file.Value != String.Empty)
            {
                string fileName = ((IConfigXmlNode)section).Filename;
                fileName = Path.GetFullPath(fileName);
                string fullPath = Path.Combine(Path.GetDirectoryName(fileName), file.Value);
                if (!File.Exists(fullPath))
                {
                    return(pairs);
                }

                ConfigXmlDocument doc = new ConfigXmlDocument();
                doc.Load(fullPath);
                if (doc.DocumentElement.Name != section.Name)
                {
                    throw new ConfigurationException("Invalid root element", doc.DocumentElement);
                }

                pairs = ConfigHelper.GetNameValueCollection(pairs, doc.DocumentElement,
                                                            "key", "value");
            }

            return(pairs);
#else
            return(null);
#endif
        }
Beispiel #3
0
 /// <summary>
 ///		Creates a new configuration handler and adds the specified configuration object to the collection.
 /// </summary>
 /// <param name="parent">Composed from the configuration settings in a corresponding parent configuration section.</param>
 /// <param name="context">Provides access to the virtual path for which the configuration section handler computes configuration values. Normally this parameter is reserved and is null.</param>
 /// <param name="section">The XML node that contains the configuration information to be handled. section provides direct access to the XML contents of the configuration section.</param>
 /// <returns></returns>
 public object Create(object parent, object context, XmlNode section)
 {
     return(ConfigHelper.GetNameValueCollection(parent as NameValueCollection, section,
                                                KeyAttributeName, ValueAttributeName));
 }