/// <summary> /// Creates a new EquivalenceNode containing the passed node and the specified nodes from the UnknownArguments list. /// The arguments are removed from the UnknownArguments list after being added to the EquivalenceNode. /// </summary> /// <param name="equivalentNode">The first node to add to the EquivalenceNode, i.e. the node that the unknown arguments are equivalent with.</param> /// <param name="equivalentUnknownArgs">The UnknownArguments to include in the equivalence.</param> /// <returns>An EquivalenceNode containing the passed node and the specified nodes from the UnknownArguments list.</returns> /// <exception cref="System.ArgumentNullException">equivalentNode is null.</exception> /// <exception cref="System.ArgumentNullException">equivalentUnknownArgs is null.</exception> public virtual EquivalenceNode CreateEquivalenceFromUnknownArguments(Node equivalentNode, IEnumerable <Node> equivalentUnknownArgs) { if (equivalentNode == null) { throw new ArgumentNullException("equivalentNode"); } if (equivalentUnknownArgs == null) { throw new ArgumentNullException("equivalentUnknownArgs"); } EquivalenceNode equivNode = new EquivalenceNode(equivalentNode); //add specified UnknownArguments to the equivalence foreach (var equivArg in equivalentUnknownArgs) { if (!this.UnknownArguments.Contains(equivArg)) { throw new InvalidOperationException(string.Format("Node is not present in the UnknownArguments collection: {0}", equivArg)); } equivNode.AddEquivalentNode(equivArg); } //remove equivalent arguments from the UnknownArguments list this.UnknownArguments.RemoveAll(n => equivalentUnknownArgs.Contains(n)); return(equivNode); }
/// <summary> /// Creates a new EquivalenceNode containing the passed node and the specified nodes from the UnknownArguments list. /// The arguments are removed from the UnknownArguments list after being added to the EquivalenceNode. /// </summary> /// <param name="equivalentNode">The first node to add to the EquivalenceNode, i.e. the node that the unknown arguments are equivalent with.</param> /// <param name="equivalentUnknownArgs">The UnknownArguments to include in the equivalence.</param> /// <returns>An EquivalenceNode containing the passed node and the specified nodes from the UnknownArguments list.</returns> /// <exception cref="System.ArgumentNullException">equivalentNode is null.</exception> /// <exception cref="System.ArgumentNullException">equivalentUnknownArgs is null.</exception> public virtual EquivalenceNode CreateEquivalenceFromUnknownArguments(Node equivalentNode, IEnumerable<Node> equivalentUnknownArgs) { if(equivalentNode == null) { throw new ArgumentNullException("equivalentNode"); } if(equivalentUnknownArgs == null) { throw new ArgumentNullException("equivalentUnknownArgs"); } EquivalenceNode equivNode = new EquivalenceNode(equivalentNode); //add specified UnknownArguments to the equivalence foreach(var equivArg in equivalentUnknownArgs) { if(!this.UnknownArguments.Contains(equivArg)) { throw new InvalidOperationException(string.Format("Node is not present in the UnknownArguments collection: {0}", equivArg)); } equivNode.AddEquivalentNode(equivArg); } //remove equivalent arguments from the UnknownArguments list this.UnknownArguments.RemoveAll(n => equivalentUnknownArgs.Contains(n)); return equivNode; }