本文整理汇总了C#中System.Collections.Stack.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.Clear方法的具体用法?C# Stack.Clear怎么用?C# Stack.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Stack
的用法示例。
在下文中一共展示了Stack.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Declare stack collection
Stack myStack = new Stack();
// Push elements onto the stack
myStack.Push("item 1");
myStack.Push("item 2");
myStack.Push("item 3");
// Display number of items
Console.WriteLine("{0} Items on the stack", myStack.Count);
// Have a peek at the item on top
Console.WriteLine("{0}", myStack.Peek());
// Pop off an element
myStack.Pop(); // gets top value
// Have a peek at the item on top
Console.WriteLine("{0}", myStack.Peek());
// Clear stack
myStack.Clear();
// Display number of items
Console.WriteLine("{0} Items on the stack", myStack.Count);
Console.ReadLine();
}
示例2: LoadXml
public void LoadXml(string xml)
{
root = null;
#if CF_1_0
stack = new Stack ();
#else
stack.Clear();
#endif
Parse(new StringReader(xml), this);
}
示例3: ClearResetsNumberOfElementsToZero
public static void ClearResetsNumberOfElementsToZero()
{
int iNumElementsAdded = 2;
Stack stack = new Stack();
for (int i = 0; i < iNumElementsAdded; i++)
{
stack.Push(new Object());
}
stack.Clear();
Assert.Equal(0, stack.Count);
}
示例4: CalculateApproveFlowStepConditionExpression
/// <summary>
/// 计算条件组合表达式结果
/// </summary>
/// <param name="strConditionExpression">条件组合表达式</param>
/// <returns></returns>
public static bool CalculateApproveFlowStepConditionExpression(string strConditionExpression)
{
//1.处理表达式字符串
//1.1.全部转换为小写
strConditionExpression = strConditionExpression.ToLower();
//1.2.将and和or转换为&和|
strConditionExpression = strConditionExpression.Replace("and", "&");
strConditionExpression = strConditionExpression.Replace("or", "|");
//1.3.删除空格字符
strConditionExpression = strConditionExpression.Replace(" ", "");
//2.将中缀表达式转换成后缀表达式
strConditionExpression = TransformPostFix(strConditionExpression);
//3.运算后缀表达式
Stack stack = new Stack();
string[] arrayString = strConditionExpression.Split('$');
foreach (string str in arrayString)
{
if (str == "true" || str == "false")
{
stack.Push(Convert.ToBoolean(str));
}
else
{
try
{
bool bRight = (bool)stack.Pop();
bool bLeft = (bool)stack.Pop();
switch (str)
{
case "&": stack.Push(bLeft && bRight); break;
case "|": stack.Push(bLeft || bRight); break;
}
}
catch (InvalidOperationException e)
{
stack.Clear();
throw new Exception(e.Message);
}
}
}
return (bool)stack.Pop();
}
示例5: Main
static void Main(string[] args)
{
Stack myStack = new Stack();
myStack.Push("item 1");
myStack.Push("item 2");
myStack.Push("item 3");
Console.WriteLine("{0} Items on the stack", myStack.Count);
//Have a peek at the top item
Console.WriteLine("{0}", myStack.Peek());
myStack.Pop();
Console.WriteLine("{0}", myStack.Peek());
myStack.Clear();
Console.WriteLine("{0} Items on the stack", myStack.Count);
Console.ReadLine();
}
示例6: Main
static void Main(string[] args)
{
Stack myStack = new Stack();
myStack.Push("item 1");
myStack.Push("item 2");
myStack.Push("item 3");
Console.WriteLine("{0} Items on the stack", myStack.Count);
// Have a peek at the top item
Console.WriteLine("{0}", myStack.Peek());
myStack.Pop(); // pops "item 3" off the top
// now "item 2" is the top item
Console.WriteLine("{0}", myStack.Peek());
myStack.Clear(); // get rid of everything
Console.WriteLine("{0} Items on the stack", myStack.Count);
Console.ReadLine();
}
示例7: createOPFAuto
private void createOPFAuto(string strPath)
{
//fbdSplit.ShowDialog();
string strSavePath = strPath;
System.Collections.Stack stkImgs;
stkImgs = new System.Collections.Stack();
stkImgs.Clear();
MatchCollection mc;
if (strSavePath.Length > 2)
{
try
{
Application.UseWaitCursor = true;
toolStripStatusLabel1.Text = "Creating .OPF File... Please Wait";
this.Refresh();
string strContent = "";
string[] strLines;
strContent = rtbContent.Text;
strLines = strContent.Split('\n');
long i = strLines.Length;
toolStripProgressBar1.Maximum = Convert.ToInt32(i) + 1;
toolStripProgressBar1.Minimum = 1;
toolStripProgressBar1.Value = 1;
this.Refresh();
StreamWriter swFiles;
string strFileNames = "";
string strChapterTitle = "";
//bool blSplitStart = false;
bool blIdFound = false;
bool blSrcFound = false;
bool blTitleFound = false;
bool blATitleFound = false;
string strWrite = "";
string strIdFound = "";
string strSrcFound = "";
string strTitleFound = "";
string strATitleFound = "";
long lnImgIDCount = 1;
swFiles = new StreamWriter(strSavePath + "\\content.opf");
swFiles.WriteLine("<?xml version=\"1.0\"?>\n" +
"<package version=\"2.0\" xmlns=\"http://www.idpf.org/2007/opf\"\n" +
" unique-identifier=\"isbn\">\n" +
" <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" +
" xmlns:opf=\"http://www.idpf.org/2007/opf\">\n" +
" <dc:title>***Book Name***</dc:title> \n" +
" <dc:creator>***Author Name***</dc:creator>\n" +
" <dc:language>en-US</dc:language> \n" +
" <dc:rights>***Copyright***</dc:rights>\n" +
" <dc:publisher>***Publisher***</dc:publisher>\n" +
" <dc:identifier id=\"isbn\">****</dc:identifier>\n" +
" <meta name=\"cover\" content=\"cover-image\"/> \n" +
" </metadata>\n" +
" <manifest>\n" +
"\n" +
"<!-- Images -->\n");
for (int j = 0; j < i; j++)
{
mc = Regex.Matches(strLines[j], "<img src=\"([^\"]+)\"");
foreach (Match singleMc in mc)
{
if (stkImgs.Contains(singleMc.Result("$1")) == false)
{
stkImgs.Push(singleMc.Result("$1"));
swFiles.WriteLine(" <item href=\"" + singleMc.Result("$1") + "\" id=\"img_" + lnImgIDCount.ToString() + "\" media-type=\"image/jpeg\"/>");
lnImgIDCount++;
}
}
toolStripProgressBar1.Value = j + 1;
}
swFiles.WriteLine("<!-- NCX -->\n" +
"\n" +
"<item id=\"ncx\" href=\"toc.ncx\" media-type=\"application/x-dtbncx+xml\"/>\n" +
"\n" +
" <!-- CSS Style Sheets -->\n" +
"\n" +
"<item id=\"style_bv\" href=\"bv_ebook_style.css\" media-type=\"text/css\"/>\n" +
"<item id=\"style_basic\" href=\"stylesheet.css\" media-type=\"text/css\"/>\n" +
"<item id=\"pagetemplate\" href=\"page-template.xpgt\" media-type=\"application/vnd.adobe-page-template+xml\"/>\n" +
"<!-- Content Documents -->\n" +
"\n");
string strIDRef = " <spine toc=\"ncx\">";
//.........这里部分代码省略.........
示例8: ConvertFootNote
private void ConvertFootNote()
{
Application.UseWaitCursor = true;
toolStripStatusLabel1.Text = "Converting Footnotes ... Please Wait";
this.Refresh();
string strContent = "";
string[] strLines;
stkIDs = new System.Collections.Stack();
stkIDs.Clear();
strContent = rtbContent.Text;
strLines = strContent.Split('\n');
long i = strLines.Length;
toolStripProgressBar1.Maximum = Convert.ToInt32(i) + 1;
toolStripProgressBar1.Minimum = 1;
toolStripProgressBar1.Value = 1;
this.Refresh();
//bool blNoteStart = false;
string strFn = "";
long lnBibNo = 0;
MatchCollection mc;
#region First Loop
//Creating IDs
for (int j = 0; j < i; j++)
{
if (strLines[j].StartsWith("<note"))
{
//blNoteStart = true;
strLines[j] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE noteGroup PUBLIC \"-//OXFORD//DTD OXCHAPML//EN\" \"OxChapML.dtd\">\n" +
"<!-- [DTD] OxChapML, v2.5 -->\n" +
"<!-- [TCI] Oxford Scholarship Online Text Capture Instructions, v1.2 -->\n" +
"<!-- [TCI] OUP Bibliographic reference capture, v1.15 -->\n" +
"<noteGroup>";
}
if (strLines[j].StartsWith("</note>"))
{
//blNoteStart = false;
strLines[j] = "</noteGroup>";
}
if (strLines[j].StartsWith("<fn"))
{
strFn = Regex.Replace(strLines[j], "^<fn([0-9]+)>(.*)", "$1");
mc = Regex.Matches(strLines[j], "</bibn>", RegexOptions.RightToLeft);
int intFirstBibStart = 0;
int intFirstBibEnd = 0;
string strBIB = "";
foreach (Match singleMc in mc)
{
lnBibNo++;
intFirstBibStart = strLines[j].IndexOf("<bibn>");
intFirstBibEnd = strLines[j].IndexOf("</bibn>");
//MessageBox.Show(strLines[j]);
strBIB = strLines[j].Substring(intFirstBibStart, (intFirstBibEnd - intFirstBibStart) + 7);
//MessageBox.Show(strBIB);
strLines[j] = strLines[j].Remove(intFirstBibStart, (intFirstBibEnd - intFirstBibStart) + 7);
//MessageBox.Show(strLines[j]);
strLines[j] = strLines[j].Insert(intFirstBibStart, ConvertSingleBibn(strBIB, lnBibNo.ToString()));
//MessageBox.Show(strLines[j]);
}
strLines[j] = Regex.Replace(strLines[j], "^<fn([0-9]+)>(.*)</fn>$", "<note id=\"" + strIDPrefix + "-note-$1\" type=\"footnote\"><p><enumerator><sup>$1</sup></enumerator> $2</p></note>");
}
toolStripProgressBar1.Value = toolStripProgressBar1.Value + 1;
}
#endregion
this.Refresh();
rtbContent.Text = string.Join("\n", strLines);
toolStripStatusLabel1.Text = "Ready";
Application.UseWaitCursor = false;
}
示例9: ConvertFileNewID
private void ConvertFileNewID()
{
Application.UseWaitCursor = true;
toolStripStatusLabel1.Text = "Creating IDs... Please Wait";
this.Refresh();
string strContent = "";
string[] strLines;
stkIDs = new System.Collections.Stack();
stkIDs.Clear();
strContent = rtbContent.Text;
strLines = strContent.Split('\n');
long i = strLines.Length;
toolStripProgressBar1.Maximum = Convert.ToInt32(i);
toolStripProgressBar1.Minimum = 1;
toolStripProgressBar1.Value = 1;
this.Refresh();
string strID = "";
#region First Loop
//Creating IDs
for (int j = 0; j < i; j++)
{
if (strLines[j].StartsWith("<preface") || strLines[j].StartsWith("<chapter") || strLines[j].StartsWith("<sect") || strLines[j].StartsWith("<figure") || strLines[j].StartsWith("<table") || strLines[j].StartsWith("<sidebar") || strLines[j].StartsWith("<example") || strLines[j].StartsWith("<appendix") || strLines[j].StartsWith("<part") || strLines[j].StartsWith("<glossary")) // || strLines[j].StartsWith("<preface")
{
//MessageBox.Show(strLines[j]);
strLines[j] = Regex.Replace(strLines[j], "^(.*) id=\"([^\"]*)\"(.*)$", "$1$3");
//MessageBox.Show(strLines[j]);
strLines[j] = strLines[j].Insert(strLines[j].LastIndexOf(">"), " id=\"****\"");
//MessageBox.Show(strLines[j]);
}
toolStripProgressBar1.Increment(1);
if (strLines[j].StartsWith("<title>"))
{
strID = CreateID(Regex.Replace(strLines[j], "<title>(.*)</title>", "$1"));
if (strLines[j - 1].IndexOf("id=\"*") >= 0)
{
/*if (strLines[j - 1].StartsWith("<preface"))
{
strLines[j - 1] = strLines[j - 1].Insert(strLines[j - 1].IndexOf("id=") + 4, "preface").Replace("*", "");
}
else
{
*/
strLines[j - 1] = strLines[j - 1].Insert(strLines[j - 1].IndexOf("id=") + 4, strID).Replace("*", "");
//}
}
else
{
if (strLines[j - 2].IndexOf("id=\"*") >= 0)
{
/*
if (strLines[j - 2].StartsWith("<preface"))
{
strLines[j - 2] = strLines[j - 2].Insert(strLines[j - 2].IndexOf("id=") + 4, "preface").Replace("*", "");
}
else
{
*/
strLines[j - 2] = strLines[j - 2].Insert(strLines[j - 2].IndexOf("id=") + 4, strID).Replace("*", "");
//}
}
}
}
}
#endregion
this.Refresh();
rtbContent.Text = string.Join("\n", strLines);
toolStripStatusLabel1.Text = "Ready";
Application.UseWaitCursor = false;
}
示例10: DICTData
//.........这里部分代码省略.........
{
case 0x00:
int sidversion = (int) operandStack.Pop();
op = "version";
break;
case 0x01:
int sidNotice = (int) operandStack.Pop();
op = "Notice";
break;
case 0x02:
sidFullName = (int) operandStack.Pop();
op = "FullName";
break;
case 0x03:
int sidFamilyName = (int) operandStack.Pop();
op = "FamilyName";
break;
case 0x04:
int sidWeight = (int) operandStack.Pop();
op = "Weight";
break;
case 0x05:
operandStack.Pop();
operandStack.Pop();
operandStack.Pop();
operandStack.Pop();
op = "FontBBox";
break;
case 0x0d:
operandStack.Pop();
op = "UniqueID";
break;
case 0x0e:
operandStack.Clear();
op = "XUID";
break;
case 0x0f:
offsetCharset = (int) operandStack.Pop();
op = "charset";
break;
case 0x10:
offsetEncoding = (int) operandStack.Pop();
op = "Encoding";
break;
case 0x11:
offsetCharStrings = (int) operandStack.Pop();
op = "CharStrings";
break;
case 0x12:
offsetPrivate = (int) operandStack.Pop();
sizePrivate = (int) operandStack.Pop();
op = "Private";
break;
case 0x0c:
switch(data[cursor+1])
{
case 0x00:
int sidCopyright = (int) operandStack.Pop();
op = "Copyright";
break;
case 0x01:
operandStack.Pop();
op = "isFixedPitch";
break;
case 0x02:
operandStack.Pop();
示例11: parseCurrent
/**
* Recursively parses the token array. Recursion is used in order
* to evaluate parentheses and function arguments
*
* @param iterator an iterator of tokens
* @return the root node of the current parse stack
* @exception FormulaException if an error occurs
*/
private ParseItem parseCurrent(IEnumerator<ParseItem> iterator)
{
Stack<ParseItem> stack = new Stack<ParseItem>();
Stack<Operator> operators = new Stack<Operator>();
Stack<ParseItem> args = null; // we usually don't need this
bool parenthesesClosed = false;
ParseItem lastParseItem = null;
while (!parenthesesClosed && iterator.MoveNext())
{
ParseItem pi = iterator.Current;
if (pi == null)
break;
pi.setParseContext(parseContext);
if (pi is Operand)
handleOperand((Operand)pi, stack);
else if (pi is StringFunction)
handleFunction((StringFunction)pi, iterator, stack);
else if (pi is Operator)
{
Operator op = (Operator)pi;
// See if the operator is a binary or unary operator
// It is a unary operator either if the stack is empty, or if
// the last thing off the stack was another operator
if (op is StringOperator)
{
StringOperator sop = (StringOperator)op;
if (stack.Count == 0 || lastParseItem is Operator)
op = sop.getUnaryOperator();
else
op = sop.getBinaryOperator();
}
if (operators.Count == 0)
{
// nothing much going on, so do nothing for the time being
operators.Push(op);
}
else
{
Operator op2 = operators.Peek();
// If the last operator has a higher precedence then add this to
// the operator stack and wait
if (op2.getPrecedence() < op2.getPrecedence())
operators.Push(op2);
else if (op2.getPrecedence() == op2.getPrecedence() && op2 is UnaryOperator)
{
// The operators are of equal precedence, but because it is a
// unary operator the operand isn't available yet, so put it on
// the stack
operators.Push(op2);
}
else
{
// The operator is of a lower precedence so we can sort out
// some of the items on the stack
operators.Pop(); // remove the operator from the stack
op2.getOperands(stack);
stack.Push(op2);
operators.Push(op2);
}
}
}
else if (pi is ArgumentSeparator)
{
// Clean up any remaining items on this stack
while (operators.Count > 0)
{
Operator o = operators.Pop();
o.getOperands(stack);
stack.Push(o);
}
// Add it to the argument stack. Create the argument stack
// if necessary. Items will be stored on the argument stack in
// reverse order
if (args == null)
args = new Stack<ParseItem>();
args.Push(stack.Pop());
stack.Clear();
}
else if (pi is OpenParentheses)
{
ParseItem pi2 = parseCurrent(iterator);
Parenthesis p = new Parenthesis();
pi2.setParent(p);
//.........这里部分代码省略.........
示例12: CompileTokenFile
protected async Task CompileTokenFile(CancellationToken cancellationToken) {
try {
await TaskEx.Run(() => {
_languageRoot = new CodeTypeDeclarationRoot() { Project = _document.Project };
CodeTypeDeclarationEx initialparent = _languageRoot;
cancellationToken.ThrowIfCancellationRequested();
_dependingOnSave = this.DependingOn;
#region Clean Up
_document.Project.Solution.ErrorService.ClearAllErrorsFrom(_document, Errors.ErrorSource.ASTParser);
_codeRangeManager.Clear();
#endregion
#region Merge DependingOn Members
if(_dependingOnSave == null) {
// merge super base members
_languageRoot.Members.AddRange(_root.Members);
firstAfterNull = true;
} else {
//if(!_project.IsInUpdate) {
// if(firstAfterNull) {
// ignoreDependingOnce = true;
// _dependingOnSave.CompileTokenFileAsync();
// firstAfterNull = false;
// }
// _dependingOnSave.WaitUntilUpdated(200);
//}
_languageRoot.Members.AddRange(_dependingOnSave.GetRootTypeSnapshot().Members);
}
#endregion
var codeLineMap = _document.SegmentService.GetCodeSegmentLinesMap();
CodeTypeDeclaration parent = initialparent;
Stack<CodeSegment> paramstack = new Stack<CodeSegment>();
int linecnt = 0;
if(codeLineMap.Keys.Any())
linecnt = codeLineMap.Keys.Max();
CodeTokenLine line;
Stack<CodeTypeDeclarationEx> parentHirarchy = new Stack<CodeTypeDeclarationEx>();
int bcc = 0;
parentHirarchy.Push(initialparent);
cancellationToken.ThrowIfCancellationRequested();
#region Parse
for(int i = 0; i <= linecnt; i++) {
cancellationToken.ThrowIfCancellationRequested();
if(codeLineMap.ContainsKey(i))
line = codeLineMap[i];
else
continue;
// is class definition?:
#region Parse Class Definition
var classkeywordSegment = line.CodeSegments[0].ThisOrNextOmit(whitespacetokenNewLines);
if(classkeywordSegment != null && classkeywordSegment.Token == Token.KeyWord && classkeywordSegment.TokenString.Equals("class", StringComparison.CurrentCultureIgnoreCase)) {
var classNameSegment = classkeywordSegment.FindNextOnSameLine(Token.Identifier);
if(classNameSegment != null) {
var next = classNameSegment.NextOmit(whitespacetokenNewLines);
if(next != null) {
CodeTypeDeclarationEx thisparent = parentHirarchy.Any() ? parentHirarchy.Peek() : _languageRoot;
CodeTypeReferenceEx basecls = null;
CodeSegment refBaseClass = null;
if(next.Token == Token.KeyWord && next.TokenString.Equals("extends", StringComparison.InvariantCultureIgnoreCase)) {
refBaseClass = next.NextOmit(whitespacetokenNewLines);
if(refBaseClass != null) {
if(refBaseClass.Token == Token.Identifier) {
refBaseClass.CodeDOMObject = basecls = new CodeTypeReferenceEx(_document, refBaseClass.TokenString, thisparent);
next = refBaseClass.NextOmit(whitespacetokenNewLines);
} else {
RegisterError(_document, next.Next, "Expected: Class Name Identifier");
next = next.NextOmit(whitespacetokenNewLines);
}
} else {
if(next.Next != null && next.Next.Token != Token.BlockOpen) {
RegisterError(_document, next.Next, "Expected: Class Name Identifier");
next = next.NextOmit(whitespacetokenNewLines);
}
}
}
if(next != null) {
//.........这里部分代码省略.........
示例13: ClearActionStack
private void ClearActionStack (Stack stack)
{
foreach (EditAction action in stack)
action.Destroy ();
stack.Clear ();
}
示例14: GetListTest
public void GetListTest ()
{
ListSource lsource = new ListSource (true);
Stack stack = new Stack ();
stack.Push (3);
Assert.IsTrue (ListBindingHelper.GetList (lsource) is SimpleItem [], "#A1");
Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList"), "#A2");
Assert.AreEqual (null, ListBindingHelper.GetList (null), "#A3");
Assert.AreEqual (stack, ListBindingHelper.GetList (stack), "#A4"); // IEnumerable
Assert.IsTrue (ListBindingHelper.GetList (lsource, String.Empty) is SimpleItem [], "#B1");
Assert.AreEqual ("NonList", ListBindingHelper.GetList ("NonList", String.Empty), "#B2");
Assert.AreEqual (null, ListBindingHelper.GetList (null, "DontExist"), "#B3");
Assert.IsTrue (ListBindingHelper.GetList (lsource, null) is SimpleItem [], "#B4");
ListContainer list_container = new ListContainer ();
Assert.AreEqual (new object [0], ListBindingHelper.GetList (list_container, "List"), "#C1");
// Even if IListSource.ContainsListCollection is false, we return the result of GetList ()
lsource = new ListSource (false);
Assert.IsTrue (ListBindingHelper.GetList (lsource) is SimpleItem [], "#D1");
// DataMember is not if IList type
Assert.AreEqual (new SimpleItem (), ListBindingHelper.GetList (list_container, "NonList"), "#E1");
// List (IEnumerable)
stack.Clear ();
stack.Push (new SimpleItem (3));
stack.Push (new SimpleItem (7));
object obj = ListBindingHelper.GetList (stack, "Value");
Assert.IsTrue (obj != null, "#F1");
Assert.IsTrue (obj is int, "#F2");
Assert.AreEqual (7, (int) obj, "#F3");
// ListSource returning an IEnumerable,
// which in turn retrieves dataMember
obj = ListBindingHelper.GetList (lsource, "Value");
Assert.IsTrue (obj != null, "#G1");
Assert.IsTrue (obj is int, "#G2");
Assert.AreEqual (0, (int)obj, "#G3");
// Empty IEnumerable - valid property for list item type
// Since it's empty, it needs to check whether the datamember is
// a valid value, and thus we need the datasource to also be IList
// Then we need a parameterized IEnumerable, which returns null.
// *Observation: if it is empty and it doesn't implement IList,
// it doesn't have a way to get the properties, and will throw an exc
StringCollection str_coll = new StringCollection ();
obj = ListBindingHelper.GetList (str_coll, "Length");
Assert.IsNull (obj, "#H1");
// IEnumerable that returns instances of ICustomTypeDescriptor
// Use DataTable as source, which returns, when enumerating,
// instances of DataRowView, which in turn implement ICustomTypeDescriptor
DataTable table = new DataTable ();
table.Columns.Add ("Id", typeof (int));
table.Rows.Add (666);
object l = ListBindingHelper.GetList (table, "Id");
Assert.AreEqual (666, l, "#J1");
try {
ListBindingHelper.GetList (list_container, "DontExist");
Assert.Fail ("#EXC1");
} catch (ArgumentException) {
}
// Empty IEnumerable not implementing IList
// Don't have a way to know whether at least datamember is valid or not.
try {
stack.Clear ();
obj = ListBindingHelper.GetList (stack, "Value");
Assert.Fail ("#EXC3");
} catch (ArgumentException) {
}
}
示例15: stateTravers
private void stateTravers(StateNode tra)
{
StateLawNode lawNode=tra.laws.Head;
Stack lawExists=new Stack();
while(lawNode!=null)
{
LawsNode law=parsHead.findLaw(lawNode.data.lawNum);
if(law!=null)
{
PartsNode part=law.parts[lawNode.data.dotPos];
if(part!=null)
{
if(!part.item.isTerminal )
{
if(!lawExists.Contains(part.item.name))
{
Stack lawNumbers = new Stack();
lawNumbers.Clear();
law.parts.Parent.Parent.NonTerminals.findLaws(part.item.name,lawNumbers);
while(lawNumbers.Count != 0)
tra.laws.add(0,(int)lawNumbers.Pop());
lawExists.Push(part.item.name);
}
}
}
}
lawNode=lawNode.next;
}
}