本文整理汇总了C#中KeyValuePair.Where方法的典型用法代码示例。如果您正苦于以下问题:C# KeyValuePair.Where方法的具体用法?C# KeyValuePair.Where怎么用?C# KeyValuePair.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValuePair
的用法示例。
在下文中一共展示了KeyValuePair.Where方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTestsMatchFilterRequest
private static bool DoTestsMatchFilterRequest(string[] testTags, KeyValuePair<string, string>[] filterTags)
{
//If no tags were requested, then then it is a match
if (!filterTags.Any())
{
return true;
}
var includeTags = filterTags.Where(t => t.Value.Equals("true", StringComparison.OrdinalIgnoreCase))
.Select(t => t.Key)
.ToArray();
var excludeTags = filterTags.Where(t => t.Value.Equals("false", StringComparison.OrdinalIgnoreCase))
.Select(t => t.Key)
.ToArray();
return !excludeTags.Intersect(testTags, StringComparer.OrdinalIgnoreCase).Any() &&
includeTags.Intersect(testTags, StringComparer.OrdinalIgnoreCase).Count() == includeTags.Count();
}
示例2: RestfulResourceController
protected RestfulResourceController()
{
_allResponseFactories = new [] {
new KeyValuePair<string, ResponseFactoryDelegate<ActionResult>>("*/*", WildcardResponseFactory),
new KeyValuePair<string, ResponseFactoryDelegate<ActionResult>>("text/html", TextHtmlResponseFactory),
new KeyValuePair<string, ResponseFactoryDelegate<ActionResult>>("application/json", ApplicationJsonResponseFactory),
new KeyValuePair<string, ResponseFactoryDelegate<ActionResult>>("text/xml", TextXmlResponseFactory),
};
_responseFactories = _allResponseFactories.Where(f => SupportedAcceptHeaders.Contains(f.Key));
}
示例3: CopyTo
public void CopyTo()
{
var trie = new Trie<bool>();
trie.Add("ABC", true);
trie.Add("AB", false);
trie.Add("ADE", true);
trie.Add("ABCDE", false);
var destinationArray = new KeyValuePair<string, bool>[6];
((ICollection<KeyValuePair<string, bool>>)trie).CopyTo(destinationArray, 1);
var result = destinationArray.Where(i => i.Key != null).OrderBy(i => i.Key).ToArray();
var expected = new[]
{
new KeyValuePair<string, bool>("AB", false),
new KeyValuePair<string, bool>("ABC", true),
new KeyValuePair<string, bool>("ABCDE", false),
new KeyValuePair<string, bool>("ADE", true)
};
Assert.AreEqual(new KeyValuePair<string, bool>(), destinationArray[0]);
Assert.AreEqual(new KeyValuePair<string, bool>(), destinationArray[destinationArray.Length - 1]);
Assert.IsTrue(expected.SequenceEqual(result));
}
示例4: ChangeWhereClauseTable
private void ChangeWhereClauseTable(KeyValuePair<DataTable, DataTable>[] tables,
ref List<SqlFilterCondition> whereClause)
{
DataTable prevTable = null;
for (int i = 0; i < whereClause.Count; i++)
{
SqlFilterCondition cond = whereClause[i];
if (cond.Table != prevTable)
{
var q = tables.Where(t => t.Key.TableName == cond.Table.TableName);
if (q.Count() == 1) prevTable = q.ElementAt(0).Value;
}
if (prevTable != null)
{
cond.Table = prevTable;
whereClause[i] = cond;
}
}
}
示例5: SerializeNavigatorPopularRoomsNews
/// <summary>
/// Serializes the navigator popular rooms news.
/// </summary>
/// <param name="reply">The reply.</param>
/// <param name="rooms">The rooms.</param>
/// <param name="category">The category.</param>
/// <param name="direct">if set to <c>true</c> [direct].</param>
public void SerializeNavigatorPopularRoomsNews(ref ServerMessage reply, KeyValuePair<RoomData, uint>[] rooms,
int category, bool direct)
{
if (rooms == null || !rooms.Any())
{
reply.AppendInteger(0);
return;
}
List<RoomData> roomsCategory = new List<RoomData>();
foreach (KeyValuePair<RoomData, uint> pair in rooms.Where(pair => pair.Key.Category.Equals(category)))
{
roomsCategory.Add(pair.Key);
if (roomsCategory.Count == (direct ? 40 : 8)) break;
}
reply.AppendInteger(roomsCategory.Count);
foreach (RoomData data in roomsCategory) data.Serialize(reply, false);
}
示例6: projectFromArgs
private string projectFromArgs(KeyValuePair<string,string>[] arguments)
{
var sublimeProject = arguments
.Where(p => p.Key == "--editor.sublime.project")
.Select(p => p.Value)
.FirstOrDefault();
return sublimeProject;
}
示例7: WriteConstants
private static void WriteConstants(StringBuilder outputString, HashSet<string> usedConstants, ref KeyValuePair<string,string>[] remainingConstants, string prefix, string constantsName = null, Func<string, bool> additionalAcceptanceConstantFilter = null, Func<string, bool> additionalRejectConstantFilter = null)
{
if (string.IsNullOrEmpty(constantsName))
constantsName = FormatEnumName(prefix, "");
var constants = remainingConstants.Where(k => (k.Key.StartsWith(prefix) || (additionalAcceptanceConstantFilter != null && additionalAcceptanceConstantFilter(k.Key))) && (additionalRejectConstantFilter == null || additionalRejectConstantFilter(k.Key))).ToArray();
remainingConstants = remainingConstants.Except(constants).ToArray();
outputString.AppendLine(" enum " + constantsName);
outputString.AppendLine(" {");
foreach (var c in constants)
{
string cname = FormatEnumName(c.Key, prefix);
while (usedConstants.Contains(cname))
cname += "_";
usedConstants.Add(cname);
outputString.AppendFormat(" {0} = {1},", cname, c.Value);
outputString.AppendLine();
}
outputString.AppendLine(" };");
}