当前位置: 首页>>代码示例>>C#>>正文


C# KeyValuePair.Where方法代码示例

本文整理汇总了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();
        }
开发者ID:wli3,项目名称:Its.Log,代码行数:18,代码来源:TagConstraint.cs

示例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));
 }
开发者ID:benaston,项目名称:NOpenInterface,代码行数:10,代码来源:RestfulResourceController.cs

示例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));
        }
开发者ID:kpol,项目名称:trie,代码行数:27,代码来源:TrieTests.cs

示例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;
         }
     }
 }
开发者ID:HabitatFramework,项目名称:HLUTool,代码行数:19,代码来源:MapInfoApp.cs

示例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);
        }
开发者ID:BjkGkh,项目名称:Azure2,代码行数:25,代码来源:Navigator.cs

示例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;
 }
开发者ID:continuoustests,项目名称:EditorEngine,代码行数:8,代码来源:SublimeEditor.cs

示例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("    };");
        }
开发者ID:southpolenator,项目名称:WinDbgCs,代码行数:24,代码来源:Program.cs


注:本文中的KeyValuePair.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。