本文整理汇总了C#中System.Collections.Stack.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.Contains方法的具体用法?C# Stack.Contains怎么用?C# Stack.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Stack
的用法示例。
在下文中一共展示了Stack.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Stack ast = new Stack();
ast.Push("Item 1");
ast.Push("Item 2");
ast.Push("Item 3");
ast.Push("Item 4");
Console.WriteLine("Count: {0}", ast.Count);
PrintValues(ast);
// Peek item but do not remove
object item = ast.Peek();
Console.WriteLine("Peek: {0}", item);
PrintValues(ast);
// Peek and cast but do not remove
string itemString = ast.Peek() as string; // fast cast
Console.WriteLine("Peek: {0}", item);
PrintValues(ast);
// Contains
Boolean contains = ast.Contains("Item 3");
Console.WriteLine("Contains: {0}", contains);
// Remove items
object item4 = ast.Pop();
object item3 = ast.Pop();
Console.WriteLine("Pop: {0} {1}", item4, item3);
PrintValues(ast);
Console.WriteLine("Count: {0}", ast.Count);
// no TrimToSize method
}
示例2: ReorderStack
private static void ReorderStack(GeneralTransformationRule originalTransformationRule, Computation comp, Stack<GeneralTransformationRule> ruleStack)
{
var testTransformationRule = originalTransformationRule;
var missingStack = new Stack<GeneralTransformationRule>();
while (!ruleStack.Contains(testTransformationRule))
{
missingStack.Push(testTransformationRule);
testTransformationRule = testTransformationRule.BaseRule;
}
while (ruleStack.Peek() != testTransformationRule)
{
ruleStack.Pop();
if (ruleStack.Count == 0) throw new InvalidOperationException("The rule stack from the transformation rule did not contain the base rule of the computation");
}
while (missingStack.Count > 0)
{
testTransformationRule = missingStack.Pop();
ruleStack.Push(testTransformationRule);
}
while (!testTransformationRule.IsLeafTransformation)
{
var found = false;
foreach (var next in testTransformationRule.Children)
{
if (next.IsInstantiating(comp))
{
testTransformationRule = next;
ruleStack.Push(next);
found = true;
break;
}
}
if (!found) break;
}
}
示例3: AddChildrenAndLookForSelected
/// <summary>
///
/// </summary>
public virtual LabelNode AddChildrenAndLookForSelected (int hvoToSelect,
Stack ownershipStack, List<int> rghvoChosen)
{
LabelNode nodeRepresentingCurrentChoice = null;
// JohnT: if this.Nodes[0] is not a LabelNode, it is a dummy node we added so that
// its parent LOOKS like something we can expand. That is the usual case for a node
// we can expand. Therefore finding one of those, or finding more or less than one
// node, is evidence that we haven't previously computed the real children of this,
// and should do so.
bool fExpanded = this.Nodes.Count != 1 || (this.Nodes[0] as LabelNode) != null;
if (!fExpanded)
{
this.Nodes.Clear();
nodeRepresentingCurrentChoice = AddSecondaryNodesAndLookForSelected(this,
Nodes, nodeRepresentingCurrentChoice, hvoToSelect, ownershipStack, rghvoChosen);
foreach (ObjectLabel label in ((ObjectLabel)this.Tag).SubItems)
{
if (!WantNodeForLabel(label))
continue;
LabelNode node = Create(label, m_stylesheet);
if (rghvoChosen != null)
node.Checked = (rghvoChosen.BinarySearch(label.Hvo) >= 0);
this.Nodes.Add(node);
nodeRepresentingCurrentChoice = CheckForSelection(label, hvoToSelect,
node, nodeRepresentingCurrentChoice, ownershipStack);
nodeRepresentingCurrentChoice = AddSecondaryNodesAndLookForSelected(
node, node.Nodes, nodeRepresentingCurrentChoice, hvoToSelect,
ownershipStack, rghvoChosen);
}
}
else
{
// Even if we don't have to create children for this, we need to search the
// children for matches, and perhaps expand some of them.
foreach (LabelNode node in this.Nodes)
{
nodeRepresentingCurrentChoice = CheckForSelection(node.Label,
hvoToSelect, node, nodeRepresentingCurrentChoice, ownershipStack);
}
}
if (nodeRepresentingCurrentChoice == null)
{
foreach (LabelNode node in this.Nodes)
{
if (ownershipStack.Contains(node.Label.Hvo))
{
nodeRepresentingCurrentChoice = node.AddChildrenAndLookForSelected(
hvoToSelect, ownershipStack, rghvoChosen);
return nodeRepresentingCurrentChoice;
}
}
}
else
{
this.Expand();
nodeRepresentingCurrentChoice.EnsureVisible();
}
return nodeRepresentingCurrentChoice;
}
示例4: CheckForCircularBasedOnReferences
/// <summary>
/// This method checks to see if the BasedOn hierarchy contains
/// a loop in the chain of references.
/// </summary>
/// <remarks>
/// Classic "when did we enter the cycle" problem where we don't know
/// what to start remembering and what to check against. Brute-
/// force approach here is to remember everything with a stack
/// and do a linear comparison through everything. Since the Style
/// BasedOn hierarchy is not expected to be large, this should be OK.
/// </remarks>
private void CheckForCircularBasedOnReferences()
{
Stack basedOnHierarchy = new Stack(10); // 10 because that's the default value (see MSDN) and the perf team wants us to specify something.
Style latestBasedOn = this;
while( latestBasedOn != null )
{
if( basedOnHierarchy.Contains( latestBasedOn ) )
{
// Uh-oh. We've seen this Style before. This means
// the BasedOn hierarchy contains a loop.
throw new InvalidOperationException(SR.Get(
SRID.StyleBasedOnHasLoop));
// Debugging note: If we stop here, the basedOnHierarchy
// object is still alive and we can browse through it to
// see what we've explored. (This does not apply if
// somebody catches this exception and re-throws.)
}
// Haven't seen it, push on stack and go to next level.
basedOnHierarchy.Push( latestBasedOn );
latestBasedOn = latestBasedOn.BasedOn;
}
return;
}
示例5: ResolveEmbedded
private string ResolveEmbedded (string embeddedtag, string[] tagparts, Stack<string> resolvestack)
{
string tag = Unembed(embeddedtag, tagparts);
return resolvestack.Contains(tag) ? tag : Resolve(tag, resolvestack);
}
示例6: FlattenGroup
/// <summary>
/// Recursively processes the group.
/// </summary>
/// <param name="parentTypeAndId">String combination type and id of group to process next.</param>
/// <param name="loopDetector">Stack of groups processed thus far. Used to detect loops.</param>
/// <param name="parentGroups">Hash table of complex references grouped by parent id.</param>
/// <param name="parentGroupsNeedingProcessing">Hash table of parent groups that still have nested groups that need to be flattened.</param>
private void FlattenGroup(string parentTypeAndId, Stack loopDetector, Hashtable parentGroups, Hashtable parentGroupsNeedingProcessing)
{
Debug.Assert(parentGroupsNeedingProcessing.Contains(parentTypeAndId));
loopDetector.Push(parentTypeAndId); // push this complex reference parent identfier into the stack for loop verifying
ArrayList allNewChildComplexReferences = new ArrayList();
ArrayList referencesToParent = (ArrayList)parentGroups[parentTypeAndId];
foreach (WixComplexReferenceRow wixComplexReferenceRow in referencesToParent)
{
Debug.Assert(ComplexReferenceParentType.ComponentGroup == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.FeatureGroup == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.Feature == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.Module == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.Product == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.PatchFamilyGroup == wixComplexReferenceRow.ParentType || ComplexReferenceParentType.Patch == wixComplexReferenceRow.ParentType);
Debug.Assert(parentTypeAndId == CombineTypeAndId(wixComplexReferenceRow.ParentType, wixComplexReferenceRow.ParentId));
// We are only interested processing when the child is a group.
if ((ComplexReferenceChildType.ComponentGroup == wixComplexReferenceRow.ChildType) ||
(ComplexReferenceChildType.FeatureGroup == wixComplexReferenceRow.ChildType) ||
(ComplexReferenceChildType.PatchFamilyGroup == wixComplexReferenceRow.ChildType))
{
string childTypeAndId = CombineTypeAndId(wixComplexReferenceRow.ChildType, wixComplexReferenceRow.ChildId);
if (loopDetector.Contains(childTypeAndId))
{
// Create a comma delimited list of the references that participate in the
// loop for the error message. Start at the bottom of the stack and work the
// way up to present the loop as a directed graph.
object[] stack = loopDetector.ToArray();
StringBuilder loop = new StringBuilder();
for (int i = stack.Length - 1; i >= 0; --i)
{
loop.Append((string)stack[i]);
if (0 < i)
{
loop.Append(" -> ");
}
}
this.OnMessage(WixErrors.ReferenceLoopDetected(wixComplexReferenceRow.Table.Section == null ? null : wixComplexReferenceRow.Table.Section.SourceLineNumbers, loop.ToString()));
// Cleanup the parentGroupsNeedingProcessing and the loopDetector just like the
// exit of this method does at the end because we are exiting early.
loopDetector.Pop();
parentGroupsNeedingProcessing.Remove(parentTypeAndId);
return; // bail
}
// Check to see if the child group still needs to be processed. If so,
// go do that so that we'll get all of that children's (and children's
// children) complex references correctly merged into our parent group.
if (parentGroupsNeedingProcessing.ContainsKey(childTypeAndId))
{
this.FlattenGroup(childTypeAndId, loopDetector, parentGroups, parentGroupsNeedingProcessing);
}
// If the child is a parent to anything (i.e. the parent has grandchildren)
// clone each of the children's complex references, repoint them to the parent
// complex reference (because we're moving references up the tree), and finally
// add the cloned child's complex reference to the list of complex references
// that we'll eventually add to the parent group.
ArrayList referencesToChild = (ArrayList)parentGroups[childTypeAndId];
if (null != referencesToChild)
{
foreach (WixComplexReferenceRow crefChild in referencesToChild)
{
// Only merge up the non-group items since groups are purged
// after this part of the processing anyway (cloning them would
// be a complete waste of time).
if ((ComplexReferenceChildType.FeatureGroup != crefChild.ChildType) ||
(ComplexReferenceChildType.ComponentGroup != crefChild.ChildType) ||
(ComplexReferenceChildType.PatchFamilyGroup != crefChild.ChildType))
{
WixComplexReferenceRow crefChildClone = crefChild.Clone();
Debug.Assert(crefChildClone.ParentId == wixComplexReferenceRow.ChildId);
crefChildClone.Reparent(wixComplexReferenceRow);
allNewChildComplexReferences.Add(crefChildClone);
}
}
}
}
}
// Add the children group's complex references to the parent
// group. Clean out any left over groups and quietly remove any
// duplicate complex references that occurred during the merge.
referencesToParent.AddRange(allNewChildComplexReferences);
referencesToParent.Sort();
for (int i = referencesToParent.Count - 1; i >= 0; --i)
{
WixComplexReferenceRow wixComplexReferenceRow = (WixComplexReferenceRow)referencesToParent[i];
if ((ComplexReferenceChildType.FeatureGroup == wixComplexReferenceRow.ChildType) ||
(ComplexReferenceChildType.ComponentGroup == wixComplexReferenceRow.ChildType) ||
(ComplexReferenceChildType.PatchFamilyGroup == wixComplexReferenceRow.ChildType))
{
referencesToParent.RemoveAt(i);
}
//.........这里部分代码省略.........
示例7: ConvertToRPN
static Queue<string> ConvertToRPN(List<string> elements)
{
Stack<string> stack = new Stack<string>();
Queue<string> queue = new Queue<string>();
for (int i = 0; i < elements.Count; i++)
{
var currentElement = elements[i];
double number;
if (double.TryParse(currentElement, out number))
{
queue.Enqueue(currentElement);
}
else if (mathFunctions.Contains(currentElement))
{
stack.Push(currentElement);
}
else if (currentElement == ",")
{
if (!stack.Contains("(") || stack.Count == 0)
{
throw new ArgumentException("Invalid bracket or function operator!");
}
while (stack.Peek() != "(")
{
string currentOperator = stack.Pop();
queue.Enqueue(currentOperator);
}
}
else if (mathOperators.Contains(currentElement[0]))
{
//if not working refactor logic for operator
while (stack.Count != 0 && mathOperators.Contains(stack.Peek()[0]) && OperatorPrecedence(currentElement) <= OperatorPrecedence(stack.Peek()))
{
queue.Enqueue(stack.Pop());
}
stack.Push(currentElement);
}
else if (currentElement == "(")
{
stack.Push("(");
}
else if (currentElement == ")")
{
if (!stack.Contains("(") || stack.Count == 0)
{
throw new ArgumentException("Invalid bracket position!");
}
while (stack.Count != 0 && stack.Peek() != "(")
{
queue.Enqueue(stack.Pop());
}
stack.Pop();
if (stack.Count != 0 && mathFunctions.Contains(stack.Peek()))
{
queue.Enqueue(stack.Pop());
}
}
}
while (stack.Count != 0)
{
if (barcketSymbols.Contains(stack.Peek()[0]))
{
throw new ArgumentException("Invalid bracket position!");
}
queue.Enqueue(stack.Pop());
}
return queue;
}
示例8: getFollow
public void getFollow(string name,Stack follows , Stack checkedNonTerm)
{
if(name==nonTerminals.ExtraNonTerm)
{
follows.Push("$");
return;
}
nonTerminalNode temp=first;
while(temp!=null)
{
if( temp.lawLink.getFollow(name,follows)==true)
{
if( !checkedNonTerm.Contains(temp.item.Name))
{
checkedNonTerm.Push(temp.item.Name);
getFollow(temp.item.Name , follows,checkedNonTerm);
}
}
temp=temp.next;
}
}
示例9: makeStats
private void makeStats(int stateNumber)
{
StateNode newStateNode;
Stack exports=new Stack();
StateNode temp = this.first;
while(temp!=null)
{
if(temp.StateNumber == stateNumber)
{
StateLawNode stateLaw = temp.laws.Head;
while(stateLaw!=null)
{
LawsNode law = this.parsHead.findLaw(stateLaw.data.lawNum);
PartsNode part = law.parts[stateLaw.data.dotPos];
if(part != null)
{
if(!exports.Contains(part.item.name))
{
exports.Push(part.item.name);
newStateNode=new StateNode(this.count+1);
newStateNode.laws.add(stateLaw.data.dotPos+1,stateLaw.data.lawNum);
StateLawNode remainLaw = stateLaw.next;
while(remainLaw!=null)
{
LawsNode remLaw = this.parsHead.findLaw(remainLaw.data.lawNum);
PartsNode remPart = remLaw.parts[remainLaw.data.dotPos];
if(remPart != null)//if2
{
if(remPart.item.name==part.item.name)
{
newStateNode.laws.add(remainLaw.data.dotPos+1,remainLaw.data.lawNum);
}
}//if2
remainLaw = remainLaw.next;
}//while
this.stateTravers(newStateNode);
StateNode existState;
existState=this.isCreated(newStateNode);
if(existState==null)
{
this.add(newStateNode);
temp.exports.add(part.item.name,part.item.isTerminal,newStateNode.StateNumber);
this.makeStats(newStateNode.StateNumber);
}
else
{
temp.exports.add(part.item.name,part.item.isTerminal,existState.StateNumber);
}
}//if new export
}//if dot place is not end
else
{
stateLaw.data.IsDotEnded = true;
}
stateLaw = stateLaw.next;
}
}//if find state
temp = temp.next;
}//while in state
}
示例10: findFollows
public bool findFollows(string name,Stack follows)
{
PartsNode temp=first;
while(temp!=null)
{
if(temp.item.name==name)
{
if(temp.next==null)//if this token is the last token and there is no token next of it
{
return true;
}
else if(temp.next.item.isTerminal)//if next token is a terminal element
{
if( !follows.Contains(temp.next.item.name))
follows.Push(temp.next.item.name);
}
else //if next token is a nonterminal element
{
PartsNode t = temp.next;
nonTerminals head=this.parent.Parent.NonTerminals;
while(head.getFirst(t.item.name,follows,false) ==true ) //we must chaeck next part
{
t = t.next;
if( t == null)
return true;
if(t.item.isTerminal)
{
if(!follows.Contains(t.item.name) )
follows.Push(t.item.name);
break;
}//if
}//while
}//else
}//if
temp = temp.next;
}//while
return false;
}
示例11: findFirsts
public bool findFirsts(Stack firsts,Stack checkNonTerm)
{
PartsNode temp = first;
if(first == null)
return true;
while(temp!=null)
{
if(temp.item.isTerminal)
{
if(!firsts.Contains(temp.item.name))
firsts.Push(temp.item.name);
return false;
}
if(!checkNonTerm.Contains(temp.item.name))
{
checkNonTerm.Push(temp.item.name);
if(!this.parent.Parent.NonTerminals.getFirst(temp.item.name,firsts,checkNonTerm,false))
{
return false;
}
}
else
{
if(!this.parent.Parent.NonTerminals.haveEpsilonLaw(temp.item.name))
{
return false;
}
}
temp= temp.next;
}
return true;
}
示例12: ReferenceVerificationHelper
private static CheckResult ReferenceVerificationHelper(IElement element, ref string cycleString, Stack<IElement> visitedElements)
{
List<string> typesReferenced = new List<string>();
//Assign the current VerificationId to identify nodes that have been visited
((INamedObjectContainer)element).VerificationIndex = VerificationId;
if (visitedElements.Contains(element))
{
cycleString += "The type " + element + " causes a circular reference";
return CheckResult.Failed;
}
else
{
visitedElements.Push(element);
foreach (NamedObjectSave namedObject in element.NamedObjects)
{
if ((!namedObject.SetByContainer && !namedObject.SetByDerived) &&
namedObject.SourceType == SourceType.Entity)
{
EntitySave nosEntity = ObjectFinder.Self.GetEntitySave(namedObject.SourceClassType);
if (nosEntity != null)
{
CheckResult returnValue = ReferenceVerificationHelper(nosEntity, ref cycleString, visitedElements);
if (returnValue == CheckResult.Failed)
{
return CheckResult.Failed;
}
}
}
}
visitedElements.Pop();
return CheckResult.Passed;
}
}
示例13: PushPanel
public void PushPanel(Panel Container, Stack PanelStack, Type ControlType, bool MakeItVisible)
{
EnterWaitMode();
try
{
Control target = null;
// Lookup a control of this type
foreach (Control ctrl in Container.Controls)
{
if (ctrl.GetType() == ControlType)
{
target = ctrl;
}
}
// Create a control of this type if it doesn't exist
if (target == null)
{
target = (Control)(ControlType.GetConstructor(new Type[]{}).Invoke(new object[]{}));
target.Dock = DockStyle.Fill;
target.Visible = MakeItVisible;
Container.Controls.Add(target);
}
else
{
target.Visible = MakeItVisible;
}
// Prevent two pushes to the same panel
if (PanelStack.Count > 1 && PanelStack.Peek() == target)
{
return;
}
// Prevent recursive use of a panel in a context stack
if (PanelStack.Contains(target))
{
throw new ArgumentException(ControlType.FullName + " is already in use.");
}
// Hide previous MasterPanel, if exists
if (PanelStack.Count > 0)
{
((Control)(PanelStack.Peek())).Visible = false;
}
PanelStack.Push(target);
}
finally
{
LeaveWaitMode();
}
}
示例14: FormatValues
/// <summary>
/// Formats all public instance properties and fields from the specified object to a
/// multi-line string.
/// </summary>
/// <param name="data">The object containing public properties and/or fields.</param>
/// <param name="level">Indenting level.</param>
/// <param name="seenObjects">Stack of objects already seen along this path. Used to break reference loops.</param>
/// <returns>The formatted values of the object.</returns>
public static string FormatValues(object data, int level = 0, Stack seenObjects = null)
{
// NOTE: Nullable<T> values need no special handling because as soon as they're passed
// in an object variable, they're either null or the value itself boxed as their
// internal type. (Source: http://stackoverflow.com/a/5194550/143684)
try
{
if (seenObjects != null)
{
if (seenObjects.Contains(data))
{
return "<reference loop>";
}
if (seenObjects.Count >= 6)
{
return "<nesting too deep>";
}
}
if (data == null)
{
return "null";
}
// Block certain namespaces that contain types that are impossible to dump this way
Type dataType = data.GetType();
string typeNamespace = dataType.Namespace;
string typeName = dataType.Name;
if (typeNamespace == "System" && typeName == "Type" ||
typeNamespace == "System.Reflection" ||
typeNamespace == "System.Windows.Media" ||
typeNamespace == "System.Windows.Media.Imaging")
// NOTE: This list of namespaces may not be complete.
{
return "<blocked type " + typeNamespace + "." + typeName + ">";
}
if (data is bool ||
data is byte || data is ushort || data is uint || data is ulong ||
data is sbyte || data is short || data is int || data is long ||
data is float || data is double || data is decimal)
{
return Convert.ToString(data, CultureInfo.InvariantCulture);
}
if (data is char)
{
return "'" + data.ToString().Replace("\\", "\\\\").Replace("'", "\\'") + "'";
}
if (data is string)
{
return "\"" + ((string)data).Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
}
if (data is DateTime)
{
return ((DateTime)data).ToString("yyyy-MM-dd'T'HH:mm:ss.ffffff");
}
if (data is DateTimeOffset)
{
return ((DateTimeOffset)data).ToString("yyyy-MM-dd'T'HH:mm:ss.ffffffK");
}
if (data is TimeSpan)
{
return ((TimeSpan)data).ToString();
}
if (data is DBNull)
{
return "DBNull";
}
if (data is Enum)
{
return ((Enum)data).ToString("G") + " (" + ((Enum)data).ToString("D") + ")";
}
if (data is Guid)
{
return ((Guid)data).ToString("B");
}
if (data is IntPtr)
{
if (IntPtr.Size == 4)
return "0x" + ((IntPtr)data).ToInt32().ToString("X4");
return "0x" + ((IntPtr)data).ToInt64().ToString("X8");
}
if (data is UIntPtr)
{
if (UIntPtr.Size == 4)
return "0x" + ((UIntPtr)data).ToUInt32().ToString("X4");
return "0x" + ((UIntPtr)data).ToUInt64().ToString("X8");
}
if (data is StringBuilder)
{
return "\"" + ((StringBuilder)data).ToString().Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
}
//.........这里部分代码省略.........
示例15: MergeConfigFiles
/// <summary>
/// Merges multiple test configuration files including default and user defined ones into one XmlDocument.
/// </summary>
/// <param name="configFileNames">The names of test configuration files. It contains three elements.</param>
/// <returns>The XmlDocument which contains data of all test configuration files.</returns>
private XmlDocument MergeConfigFiles(string[] configFileNames)
{
try
{
if (configFileNames == null || configFileNames.Length < 2)
{
throw new ArgumentException("At least two PTF config files should be passed in.");
}
Logging.ApplicationLog.TraceLog("Try to load " + configFileNames.Length + " config files.");
XmlDocument docBase = new XmlDocument();
docBase.XmlResolver = null;
Logging.ApplicationLog.TraceLog("Loading configFileNames[0] :" + configFileNames[0]);
docBase.Load(XmlReader.Create(configFileNames[0], new XmlReaderSettings() { XmlResolver = null }));
Stack<XmlDocument> xmlDocs = new Stack<XmlDocument>();
Stack<string> xmlDocsName = new Stack<string>();
Stack<string> configFiles = new Stack<string>();
for (int n = 1; n < configFileNames.Length; n++)
{
if (configFileNames[n] != null) configFiles.Push(configFileNames[n]);
}
while (configFiles.Count > 0)
{
string fileName = configFiles.Pop();
// Ignore multiple reference.
if (xmlDocsName.Contains(fileName))
{
Logging.ApplicationLog.TraceLog("Ignore multiple references: " + fileName);
continue;
}
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
Logging.ApplicationLog.TraceLog("Loading config file:" + fileName);
doc.Load(XmlReader.Create(fileName, new XmlReaderSettings() { XmlResolver = null }));
xmlDocs.Push(doc);
xmlDocsName.Push(fileName);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("tc", DefaultNamespace);
XmlNode root = doc.DocumentElement;
XmlNode incNode = root.SelectSingleNode("tc:Include", nsmgr);
if (incNode != null)
{
foreach (XmlNode nod in incNode.ChildNodes)
{
FileInfo fi = new FileInfo(fileName);
string path = Path.Combine(fi.DirectoryName, nod.Attributes["name"].Value);
if (!ValidateConfigFiles(new string[] { path }, false))
{
throw new XmlException(
String.Format("Validating configuration {0} failed: {1}",
invalidFilename,
validateErrorMessages));
}
configFiles.Push(path);
}
}
}
while (xmlDocs.Count > 0)
{
XmlDocument doc = xmlDocs.Pop();
string configFileName = xmlDocsName.Pop();
try
{
MergeXmlDocument(docBase, doc);
}
catch (XmlException e)
{
throw new InvalidOperationException(
String.Format(
"Merging the configuration file ({0}) failed. " +
"Please make sure it is valid. Otherwise, please validate the Xml namespace and schema location in this file. " +
"To specify the correct Xml namespace and schema location, " +
"the TestSite tag in configuration file(s) should be " + DefaultTestSiteTag,
configFileName),
e);
}
catch (InvalidOperationException e)
{
throw new InvalidOperationException(
String.Format(
"Merging the configuration file ({0}) failed. " +
"Please make sure it is valid. Otherwise, please validate the Xml namespace and schema location in this file. " +
"To specify the correct Xml namespace and schema location, " +
"the TestSite tag in configuration file(s) should be " + DefaultTestSiteTag,
configFileName),
e);
}
}
//.........这里部分代码省略.........