예제 #1
0
        /// <summary>
        /// Parses the specified <see cref="XmlElement"/> element into a
        /// <see cref="ReplicasNode"/> object.
        /// </summary>
        /// <param name="element">
        /// A Xml element that contains the providers configuration data.
        /// </param>
        /// <returns>
        /// A <see cref="ReplicasNode"/> containing the configured 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 ReplicasNode Parse(XmlElement element)
        {
            string       group    = GetAttributeValue(element, Strings.kGroupAttribute);
            ReplicasNode replicas = new ReplicasNode(group);

            foreach (XmlNode node in element.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Element &&
                    Strings.AreEquals(node.Name, Strings.kReplicaNodeName))
                {
                    ReplicaNode replica = ReplicaNode.Parse((XmlElement)node);
                    replicas.AddChildNode(replica);
                }
            }
            return(replicas);
        }
예제 #2
0
        static IEnumerable <ProviderNode> Replicate(ReplicaNode replica,
                                                    ProvidersNodeGroup group)
        {
            List <ProviderNode> clones = new List <ProviderNode>(group.Count);

            foreach (ProviderNode provider in group)
            {
                ProviderNode clone = provider.Clone(provider.Name + replica.Name);

                List <string> aliases = new List <string>();
                foreach (string alias in clone.Aliases)
                {
                    aliases.Add(alias + replica.Name);
                }
                // replace/add the cloned options with the replica's options
                foreach (KeyValuePair <string, string> option in replica.Options)
                {
                    clone.Options[option.Key] = option.Value;
                }
                clones.Add(clone);
            }
            return(clones);
        }
예제 #3
0
    static IEnumerable<ProviderNode> Replicate(ReplicaNode replica,
      ProvidersNodeGroup group) {
      List<ProviderNode> clones = new List<ProviderNode>(group.Count);
      foreach (ProviderNode provider in group) {
        ProviderNode clone = provider.Clone(provider.Name + replica.Name);

        List<string> aliases = new List<string>();
        foreach (string alias in clone.Aliases) {
          aliases.Add(alias + replica.Name);
        }
        // replace/add the cloned options with the replica's options
        foreach (KeyValuePair<string, string> option in replica.Options) {
          clone.Options[option.Key] = option.Value;
        }
        clones.Add(clone);
      }
      return clones;
    }