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


C# KeyValuePair.Count方法代码示例

本文整理汇总了C#中KeyValuePair.Count方法的典型用法代码示例。如果您正苦于以下问题:C# KeyValuePair.Count方法的具体用法?C# KeyValuePair.Count怎么用?C# KeyValuePair.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValuePair的用法示例。


在下文中一共展示了KeyValuePair.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawPieChart

 /// <summary>
 /// Draw a piechart
 /// </summary>
 private static void DrawPieChart(ref Chart chart, KeyValuePair<string, double>[] dataSeries)
 {
     if(dataSeries == null || dataSeries.Count() == 0 || chart == null || chart.Series == null)
     {
         return;
     }
     if (chart.Series != null && chart.Series.Count == 0)
     {
         chart.Series.Add(new PieSeries());
     }
     ((PieSeries)chart.Series[0]).ItemsSource = dataSeries;
 }
开发者ID:Catlady,项目名称:radseq_dotnetbio,代码行数:15,代码来源:Ploidulator.xaml.cs

示例2: UT_CacheDictionaryObject

 public void UT_CacheDictionaryObject(Context context)
 {
     string key1 = "UT_CacheDictionaryObject1";
     context.Cache.Remove(key1);
     var users = GetUsers();
     var rd = context.Collections.GetRedisDictionary<int, User>(key1);
     // Test AddMultiple
     var usersKv = users.Select(x => new KeyValuePair<int, User>(x.Id, x));
     rd.AddRange(usersKv);
     // Test GetEnumerator
     foreach (var item in rd)
     {
         Assert.IsTrue(users.Any(u => u.Id == item.Key));
     }
     // Test Count
     Assert.AreEqual(users.Count, rd.Count);
     // Test ContainsKey
     Assert.IsTrue(rd.ContainsKey(users[1].Id));
     // Test Contains
     Assert.IsTrue(rd.Contains(new KeyValuePair<int, User>(users.Last().Id, users.Last())));
     // Test Add
     rd.Add(0, new User() {Id = 0});
     Assert.AreEqual(users.Count + 1, rd.Count);
     Assert.AreEqual(0, rd[0].Id);
     // Test Remove
     rd.Remove(0);
     Assert.IsFalse(rd.ContainsKey(0));
     // Test Keys
     foreach (var k in rd.Keys)
     {
         Assert.IsTrue(users.Any(u => u.Id == k));
     }
     // Test Values
     foreach (var u in rd.Values)
     {
         Assert.IsTrue(users.Any(user => user.Id == u.Id));
     }
     // Test TryGetValue
     User userTest = new User();
     bool b = rd.TryGetValue(999, out userTest);
     Assert.IsFalse(b);
     Assert.IsNull(userTest);
     b = rd.TryGetValue(1, out userTest);
     Assert.IsTrue(b);
     Assert.AreEqual(1, userTest.Id);
     // Test CopyTo
     var array = new KeyValuePair<int, User>[50];
     rd.CopyTo(array, 10);
     Assert.AreEqual(users.Count, array.Count(x => x.Value != null));
     // Test Clear
     rd.Clear();
     Assert.AreEqual(0, rd.Count);
 }
开发者ID:chenzuo,项目名称:CachingFramework.Redis,代码行数:53,代码来源:UnitTestRedisObjects.cs

示例3: GetTransactionsForSearchCriterias

        public void GetTransactionsForSearchCriterias(KeyValuePair<string, string>[] queryExpected,
                                                      ConsumerTransactionsTestSource.FunctionHolder getCall)
        {
            var httpClient = Substitute.For<IHttpClient>();
            var response = new HttpResponseMessage(HttpStatusCode.OK) {Content = new StringContent(@"{
                            receiptId : '134567',
                            type : 'Create',
                            judoId : '12456',
                            originalAmount : 20,
                            amount : 20,
                            netAmount : 20,
                            cardDetails :
                                {
                                    cardLastfour : '1345',
                                    endDate : '1214',
                                    cardToken : 'ASb345AE',
                                    cardType : 'VISA'
                                },
                            currency : 'GBP',
                            consumer :
                                {
                                    consumerToken : 'B245SEB',
                                    yourConsumerReference : 'Consumer1'
                                }
                            }")};

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource<HttpResponseMessage>();
            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Any<HttpRequestMessage>()).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient,
                                                    DotNetLoggerFactory.Create,
                                                    "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            getCall.Func(judo.Consumers);

            httpClient.Received().SendAsync(Arg.Any<HttpRequestMessage>());
            var calls = httpClient.ReceivedCalls();

            // ReSharper disable once PossibleNullReferenceException
            var request = calls.FirstOrDefault(call => call.GetMethodInfo().Name == "SendAsync").
                                    GetArguments().FirstOrDefault() as HttpRequestMessage;

            Assert.IsNotNull(request);

            var numberOfMatchingParameters = request.RequestUri.Query
                                    .Remove(0, 1)
                                    .Split('&').Select(kv =>
                                    {
                                        var keyValue = kv.Split('=');
                                        return new KeyValuePair<string, string>(keyValue[0], keyValue[1]);
                                    }).Intersect(queryExpected).Count();

            Assert.AreEqual(queryExpected.Count(), numberOfMatchingParameters);
            Assert.AreEqual("payments", request.RequestUri.AbsolutePath.Split('/').Last());
        }
开发者ID:JudoPay,项目名称:DotNetSDK,代码行数:60,代码来源:ConsumerTransactionsTests.cs


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