本文整理汇总了C#中StringSet.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# StringSet.Contains方法的具体用法?C# StringSet.Contains怎么用?C# StringSet.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet.Contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldRemoveAndContainsReturnFalse
public void ShouldRemoveAndContainsReturnFalse()
{
var stringSet = new StringSet();
stringSet.Add("Test");
Assert.IsTrue(stringSet.Contains("Test"));
stringSet.Remove("Test");
Assert.IsFalse(stringSet.Contains("Test"));
}
示例2: ShouldEnumerate
public void ShouldEnumerate()
{
var stringSet = new StringSet();
stringSet.Add("Test");
stringSet.Add("Test");
stringSet.Add("Test");
foreach (var test in stringSet)
{
Assert.IsTrue(stringSet.Contains(test));
}
}
示例3: FilterBracesInExpectedSet
private StringSet FilterBracesInExpectedSet(StringSet stateExpectedSet) {
var result = new StringSet();
result.UnionWith(stateExpectedSet);
//Find what brace we expect
var nextClosingBrace = string.Empty;
if (OpenBraces.Count > 0) {
var lastOpenBraceTerm = OpenBraces.Peek().KeyTerm;
var nextClosingBraceTerm = lastOpenBraceTerm.IsPairFor as KeyTerm;
if (nextClosingBraceTerm != null)
nextClosingBrace = nextClosingBraceTerm.Text;
}
//Now check all closing braces in result set, and leave only nextClosingBrace
foreach(var closingBrace in Language.GrammarData.ClosingBraces) {
if (result.Contains(closingBrace) && closingBrace != nextClosingBrace)
result.Remove(closingBrace);
}
return result;
}
示例4: GetCurrentExpectedSymbols
private StringList GetCurrentExpectedSymbols()
{
BnfTermList inputElements = new BnfTermList();
StringSet inputKeys = new StringSet();
inputKeys.AddRange(_currentState.Actions.Keys);
//First check all NonTerminals
foreach (NonTerminal nt in Data.NonTerminals) {
if (!inputKeys.Contains(nt.Key)) continue;
//nt is one of our available inputs; check if it has an alias. If not, don't add it to element list;
// and we have already all its "Firsts" keys in the list.
// If yes, add nt to element list and remove
// all its "fists" symbols from the list. These removed symbols will be represented by single nt alias.
if (string.IsNullOrEmpty(nt.DisplayName))
inputKeys.Remove(nt.Key);
else {
inputElements.Add(nt);
foreach(string first in nt.Firsts)
inputKeys.Remove(first);
}
}
//Now terminals
foreach (Terminal term in Data.Terminals) {
if (inputKeys.Contains(term.Key))
inputElements.Add(term);
}
StringList result = new StringList();
foreach(BnfTerm term in inputElements)
result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName);
result.Sort();
return result;
}
示例5: ShouldAddStringAndContainsReturnTrue
public void ShouldAddStringAndContainsReturnTrue()
{
var stringSet = new StringSet();
stringSet.Add("Test");
Assert.IsTrue(stringSet.Contains("Test"));
}
示例6: CheckAliases
protected void CheckAliases(TranslationContext context, IEnumerable<Expression> outExpressions)
{
var sqlExpressions = outExpressions.OfType<SqlExpression>().ToList();
var allNames = new StringSet();
foreach(var outExpr in sqlExpressions) {
string outName = null;
var col = outExpr as ColumnExpression;
if (col != null) {
//if (isView) col.Alias = col.Name;
outName = col.Alias ?? col.Name;
}
var needsAlias = outName != null && allNames.Contains(outName);
if(outName != null)
allNames.Add(outName);
if(needsAlias)
outExpr.Alias = CreateDefaultAlias(outExpr, allNames);
}//foreach outExpr
}
示例7: GetTableConstraints
public override DataTable GetTableConstraints()
{
var dtAll = GetSchemaCollection("ForeignKeys"); //this gives us only foreign keys
// We need to add PKs; Each PK in SQLite is 'supported' by an index named 'sqlite_autoindex_*'
// We scan index columns to pick up such names and add PK rows to dtAll.
//Add PKs by scanning index columns and finding special-named indexes (starting with sqlite_autoindex)
var dtIndexes = GetIndexColumns();
var tNames = new StringSet(); //track tables to prevent duplicates
foreach(DataRow row in dtIndexes.Rows) {
var ixName = row.GetAsString("INDEX_NAME");
if(!IsPrimaryKeyIndex(ixName))
continue;
var tblName = row.GetAsString("TABLE_NAME");
if (tNames.Contains(tblName)) continue; //don't add duplicates
tNames.Add(tblName);
//it is auto-index for PK, create a row for the index
var pkRow = dtAll.NewRow();
pkRow["TABLE_NAME"] = tblName;
pkRow["CONSTRAINT_NAME"] = row.GetAsString("INDEX_NAME");
pkRow["CONSTRAINT_TYPE"] = "PRIMARY KEY";
dtAll.Rows.Add(pkRow);
}
return dtAll;
}