/// <summary>
    /// Parses the specified <see cref="XmlElement"/> element into a
    /// <see cref="DataProviderNode"/> object.
    /// </summary>
    /// <param name="element">
    /// A Xml element that contains the data provider configuration data.
    /// </param>
    /// <param name="base_directory">
    /// The base directory to use when resolving the repository's location.
    /// </param>
    /// <exception cref="ConfigurationException">
    /// The <paramref name="element"/> contains invalid configuration data.
    /// </exception>
    /// <exception cref="DirectoryNotFoundException">
    /// <paramref name="base_directory"/> does not exists.
    /// </exception>
    public static DataProviderNode Parse(XmlElement element,
      string base_directory) {
      CheckPreconditions(element, base_directory);

      string name = GetAttributeValue(element, Strings.kNameAttribute);
      string type = GetAttributeValue(element, Strings.kTypeAttribute);
      string location = GetLocation(element, base_directory);
      string alias = GetAttributeValue(element, Strings.kAliasAttribute,
        string.Empty);

      DataProviderNode node = new DataProviderNode(name, alias, type, location);
      node.options = GetOptions(element);
      return node;
    }
示例#2
0
        /// <summary>
        /// Parses the specified <see cref="XmlElement"/> element into a
        /// <see cref="DataProvidersNode"/> object.
        /// </summary>
        /// <param name="element">
        /// A Xml element that contains the repositories configuration data.
        /// </param>
        /// <param name="base_directory">
        /// The base directory to use when resolving the providers's location.
        /// </param>
        /// <returns>
        /// A <see cref="DataProvidersNode"/> containing the configured cache
        /// providers.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="element"/> is a <c>null</c> reference.
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// The <paramref name="element"/> contains invalid configuration data.
        /// </exception>
        public static DataProvidersNode Parse(XmlElement element, string base_directory)
        {
            CheckPreconditions(element, base_directory);
            DataProvidersNode providers = new DataProvidersNode();

            foreach (XmlElement node in element.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Element &&
                    StringsAreEquals(node.Name, Strings.kProviderNodeName))
                {
                    providers.AddChildNode(
                        DataProviderNode.Parse(element, base_directory));
                }
            }
            return(providers);
        }
        /// <summary>
        /// Parses the specified <see cref="XmlElement"/> element into a
        /// <see cref="DataProviderNode"/> object.
        /// </summary>
        /// <param name="element">
        /// A Xml element that contains the data provider configuration data.
        /// </param>
        /// <param name="base_directory">
        /// The base directory to use when resolving the repository's location.
        /// </param>
        /// <exception cref="ConfigurationException">
        /// The <paramref name="element"/> contains invalid configuration data.
        /// </exception>
        /// <exception cref="DirectoryNotFoundException">
        /// <paramref name="base_directory"/> does not exists.
        /// </exception>
        public static DataProviderNode Parse(XmlElement element,
                                             string base_directory)
        {
            CheckPreconditions(element, base_directory);

            string name     = GetAttributeValue(element, Strings.kNameAttribute);
            string type     = GetAttributeValue(element, Strings.kTypeAttribute);
            string location = GetLocation(element, base_directory);
            string alias    = GetAttributeValue(element, Strings.kAliasAttribute,
                                                string.Empty);

            DataProviderNode node = new DataProviderNode(name, alias, type, location);

            node.options = GetOptions(element);
            return(node);
        }