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


C# List.OrderByDescending方法代码示例

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


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

示例1: GetFindPackageResult

        private static string GetFindPackageResult(string url, List<Package> packages, bool latestVersion)
        {
            string apiUri = url.Replace("&", "&amp;");
            Uri uri = new Uri(apiUri);

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            entry[] entries = latestVersion
                ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) }
                : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray();

            feed feed = new feed
            {
                @base = InvokeUrl + "/",
                id = WebUtility.HtmlDecode(uri.ToString()),
                title = new feedTitle("FindPackagesById"),
                updated = updated,
                link = new feedLink("FindPackagesById", "FindPackagesById"),
                entry = entries
            };

            XmlSerializer serializer = new XmlSerializer(typeof(feed));
            MemoryStream ms = new MemoryStream();
            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return new StreamReader(ms).ReadToEnd();
        }
开发者ID:abelsilva,项目名称:nugetory,代码行数:29,代码来源:FindPackageControllerGetTests.cs

示例2: GetSearchResult

        private static string GetSearchResult(List<Package> packages)
        {
            Uri uri = new Uri(BaseUrl);
            string baseUri = uri.Scheme + "://" + uri.Host + ":" + uri.Port;
            string apiUri = baseUri + "/api/v2/";

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            SeachFeed.feed feed = new SeachFeed.feed
            {
                @base = apiUri,
                count = packages.Count,
                updated = updated,
                link = new SeachFeed.feedLink(apiUri + "Packages"),
                entry = packages.Select(p => Search.GetPackageEntry(p, uri)).ToArray()
            };

            XmlSerializer serializer = new XmlSerializer(typeof(SeachFeed.feed));
            MemoryStream ms = new MemoryStream();
            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return new StreamReader(ms).ReadToEnd();
        }
开发者ID:abelsilva,项目名称:nugetory,代码行数:25,代码来源:SearchControllerGetTests.cs

示例3: XX

        public void XX()
        {
            var x = new List<int> {1, 2, 3};

            x.OrderByDescending(xa => xa == 2)
                .ToList()
                .ForEach(a => Console.WriteLine(a.ToString()));
        }
开发者ID:InfiniteComputingSystems,项目名称:Test,代码行数:8,代码来源:TryTheRulesOut.cs

示例4: SortPosts

        private List<JsonPost> SortPosts(DateTime now, List<JsonPost> posts)
        {
            foreach (var post in posts)
            {
                post.EffectiveScore = Sorting.Hot(post.Score, post.Created.ToUnixTime());
            }

            return posts.OrderByDescending(x => x.EffectiveScore).ToList();
        }
开发者ID:richardrcruzc,项目名称:skimur,代码行数:9,代码来源:SortTests.cs

示例5: CanSortAListOfPlayerScores

        public void CanSortAListOfPlayerScores()
        {
            List<PlayerScore> list = new List<PlayerScore>() { second_worst, best, second_best, worst };

            var sortedList = list.OrderByDescending((p) => p).ToList();

            Assert.AreEqual(best, sortedList[0]);
            Assert.AreEqual(second_best, sortedList[1]);
            Assert.AreEqual(second_worst, sortedList[2]);
            Assert.AreEqual(worst, sortedList[3]);
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:11,代码来源:PlayerScoreTests.cs

示例6: PrefixesShouldBeSortedCorrectly

        public void PrefixesShouldBeSortedCorrectly()
        {
            var usortedPrefixesList = new List<Prefix>
            {
                Prefix.Kb, Prefix.Mb, Prefix.Gb, Prefix.Gb, Prefix.Kb, Prefix.Tb, Prefix.Gb, Prefix.Mb,Prefix.Tb, Prefix.Gb, Prefix.Mb, Prefix.Kb
            };

            usortedPrefixesList.OrderBy(it => it).Should().BeInAscendingOrder();

            usortedPrefixesList.OrderByDescending(it => it).Should().BeInDescendingOrder();
        }
开发者ID:klym1,项目名称:Toloka-Archive,代码行数:11,代码来源:TestPrefixClass.cs

示例7: only_highest_scores_are_stored_in_highscores

        public void only_highest_scores_are_stored_in_highscores()
        {
            var highScores = new HighScores();
            var randomGenerator = new Random();
            var generatedNumbers = new List<int>();
            for (int i = 0; i < 20; i++)
            {
                var number = randomGenerator.Next();
                highScores.Add(new Score(number));
                generatedNumbers.Add(number);
            }

            Assert.AreEqual(generatedNumbers.OrderByDescending(x => x).Take(10).Min(), highScores.Min().Points);
        }
开发者ID:ktwarogal,项目名称:hopnet,代码行数:14,代码来源:HighScoresTest.cs

示例8: OrderByDescending_EmailAddress_AreEqual

        public void OrderByDescending_EmailAddress_AreEqual()
        {
            var item0 = EmailAddress.Parse("[email protected]");
            var item1 = EmailAddress.Parse("[email protected]");
            var item2 = EmailAddress.Parse("[email protected]");
            var item3 = EmailAddress.Parse("[email protected]");

            var inp = new List<EmailAddress>() { EmailAddress.Empty, item3, item2, item0, item1, EmailAddress.Empty };
            var exp = new List<EmailAddress>() { item3, item2, item1, item0, EmailAddress.Empty, EmailAddress.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
开发者ID:Corniel,项目名称:Qowaiv,代码行数:13,代码来源:EmailAddressTest.cs

示例9: GetChecklistsShouldSortResultsIfGivenValidSortKey

        public void GetChecklistsShouldSortResultsIfGivenValidSortKey()
        {
            // Arrange
            var repositoryChecklists = new List<ChecklistDto>()
            {
                new ChecklistDto
                {
                    Title = "C",
                    FileNumber = 3,
                    CreatedAt = new DateTime(2015, 3, 1),
                    LastModified = new DateTime(2015, 3, 1)
                },
                new ChecklistDto
                {
                    Title = "B",
                    FileNumber = 2,
                    CreatedAt = new DateTime(2015, 2, 1),
                    LastModified = new DateTime(2015, 2, 1)
                },
                new ChecklistDto
                {
                    Title = "A",
                    FileNumber = 1,
                    CreatedAt = new DateTime(2015, 1, 1),
                    LastModified = new DateTime(2015, 1, 1)
                }
            };

            var sortedByTitleAsc = repositoryChecklists.OrderBy(c => c.Title);
            var sortedByTitleDesc = repositoryChecklists.OrderByDescending(c => c.Title);
            var sortedByFileNumAsc = repositoryChecklists.OrderBy(c => c.FileNumber);
            var sortedByFileNumDesc = repositoryChecklists.OrderByDescending(c => c.FileNumber);
            var sortedByCreatedAtAsc = repositoryChecklists.OrderBy(c => c.CreatedAt);
            var sortedByCreatedAtDesc = repositoryChecklists.OrderByDescending(c => c.CreatedAt);
            var sortedByLastModifiedAsc = repositoryChecklists.OrderBy(c => c.LastModified);
            var sortedByLastModifiedDesc = repositoryChecklists.OrderByDescending(c => c.LastModified);

            var fakeRepository = A.Fake<IChecklistRepository>();
            A.CallTo(() => fakeRepository.GetChecklists()).Returns(repositoryChecklists.AsQueryable());

            var startup = new Startup
            {
                ControllerConfiguration = new ControllerConfiguration { PageSizeLimit = 100 },
                ChecklistRepository = fakeRepository
            };

            using (WebApp.Start(BaseApiUriString, startup.Configuration))
            {
                var client = new HttpClient();

                // Act
                var sortedByTitleAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=Title&sortDirection=asc")).Result;
                var returnedSortedByTitleAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByTitleAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByTitleDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=Title&sortDirection=desc")).Result;
                var returnedSortedByTitleDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByTitleDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByFileNumAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=FileNumber&sortDirection=a")).Result;
                var returnedSortedByFileNumAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByFileNumAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByFileNumDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=FileNumber&sortDirection=d")).Result;
                var returnedSortedByFileNumDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByFileNumDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByCreatedAtAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=CreatedAt&sortDirection=ascending")).Result;
                var returnedSortedByCreatedAtAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByCreatedAtAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByCreatedAtDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=CreatedAt&sortDirection=descending")).Result;
                var returnedSortedByCreatedAtDesc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByCreatedAtDescResponse.Content.ReadAsStringAsync().Result);

                var sortedByLastModifiedAscResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=LastModified&sortDirection=Ascending")).Result;
                var returnedSortedByLastModifiedAsc = JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByLastModifiedAscResponse.Content.ReadAsStringAsync().Result);

                var sortedByLastModifiedDescResponse = client.GetAsync(new Uri(BaseApiUriString + "/api/checklists?sortField=LastModified&sortDirection=Descending")).Result;
                var returnedSortedByLastModifiedDesc= JsonConvert.DeserializeObject<List<ChecklistDto>>(sortedByLastModifiedDescResponse.Content.ReadAsStringAsync().Result);

                // Assert
                Assert.That(sortedByTitleAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByTitleAsc.SequenceEqual(returnedSortedByTitleAsc));

                Assert.That(sortedByTitleDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByTitleDesc.SequenceEqual(returnedSortedByTitleDesc));

                Assert.That(sortedByFileNumAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByFileNumAsc.SequenceEqual(returnedSortedByFileNumAsc));

                Assert.That(sortedByFileNumDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByFileNumDesc.SequenceEqual(returnedSortedByFileNumDesc));

                Assert.That(sortedByCreatedAtAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByCreatedAtAsc.SequenceEqual(returnedSortedByCreatedAtAsc));

                Assert.That(sortedByCreatedAtDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByCreatedAtDesc.SequenceEqual(returnedSortedByCreatedAtDesc));

                Assert.That(sortedByLastModifiedAscResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByLastModifiedAsc.SequenceEqual(returnedSortedByLastModifiedAsc));

                Assert.That(sortedByLastModifiedDescResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.True(sortedByLastModifiedDesc.SequenceEqual(returnedSortedByLastModifiedDesc));
            }
//.........这里部分代码省略.........
开发者ID:denholms,项目名称:LSCS,代码行数:101,代码来源:GetChecklistTests.cs

示例10: OrderByDescending_LocalDateTime_AreEqual

        public void OrderByDescending_LocalDateTime_AreEqual()
        {
            var item0 = new LocalDateTime(1900, 10, 01, 22, 10, 16);
            var item1 = new LocalDateTime(1963, 08, 23, 23, 59, 15);
            var item2 = new LocalDateTime(1999, 12, 05, 04, 13, 14);
            var item3 = new LocalDateTime(2010, 07, 13, 00, 44, 13);

            var inp = new List<LocalDateTime>() { LocalDateTime.MinValue, item3, item2, item0, item1, LocalDateTime.MinValue };
            var exp = new List<LocalDateTime>() { item3, item2, item1, item0, LocalDateTime.MinValue, LocalDateTime.MinValue };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
开发者ID:Corniel,项目名称:Qowaiv,代码行数:13,代码来源:LocalDateTimeTest.cs

示例11: OrderByDescending_WeekDate_AreEqual

        public void OrderByDescending_WeekDate_AreEqual()
        {
            var item0 = WeekDate.Parse("2000-W01-3");
            var item1 = WeekDate.Parse("2000-W11-2");
            var item2 = WeekDate.Parse("2000-W21-1");
            var item3 = WeekDate.Parse("2000-W31-7");

            var inp = new List<WeekDate>() { WeekDate.MinValue, item3, item2, item0, item1, WeekDate.MinValue };
            var exp = new List<WeekDate>() { item3, item2, item1, item0, WeekDate.MinValue, WeekDate.MinValue };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
开发者ID:Corniel,项目名称:Qowaiv,代码行数:13,代码来源:WeekDateTest.cs

示例12: OrderByDescending_Month_AreEqual

        public void OrderByDescending_Month_AreEqual()
        {
            var item0 = Month.January;
            var item1 = Month.March;
            var item2 = Month.April;
            var item3 = Month.December;

            var inp = new List<Month>() { Month.Empty, item3, item2, item0, item1, Month.Empty };
            var exp = new List<Month>() { item3, item2, item1, item0, Month.Empty, Month.Empty };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
开发者ID:helderman,项目名称:Qowaiv,代码行数:13,代码来源:MonthTest.cs

示例13: OrderByDescending_Distance_AreEqual

		public void OrderByDescending_Distance_AreEqual()
		{
			Distance item0 = 13245d;
			Distance item1 = 23245d;
			Distance item2 = 43245d;
			Distance item3 = 73245d;

			var inp = new List<Distance>() { Distance.Zero, item3, item2, item0, item1, Distance.Zero };
			var exp = new List<Distance>() { item3, item2, item1, item0, Distance.Zero, Distance.Zero };
			var act = inp.OrderByDescending(item => item).ToList();

			CollectionAssert.AreEqual(exp, act);
		}
开发者ID:Corniel,项目名称:CloudBall.LostKeysUnited,代码行数:13,代码来源:DistanceTest.cs

示例14: FindLargestPandigitalNumberThatIsAConcatenatedProduct

        public void FindLargestPandigitalNumberThatIsAConcatenatedProduct()
        {
            var products = new List<PandigitalMultiple>();

            for (var number = 1; number < 100000; ++number)
            {
                var result = CheckIfCanGeneratePandigital(number);
                if (result > 0)
                {
                    products.Add(new PandigitalMultiple(result, number, 0));
                }
            }

            foreach (var result in products.OrderByDescending(p => p.Product))
            {
                Console.WriteLine(result);
            }
        }
开发者ID:kajones,项目名称:Puzzles,代码行数:18,代码来源:Problem_0038_PandigitalMultiples.cs

示例15: OrderByDescending_Amount_AreEqual

        public void OrderByDescending_Amount_AreEqual()
        {
            Amount item0 = 0.23;
            Amount item1 = 1.24;
            Amount item2 = 2.27;
            Amount item3 = 1300;

            var inp = new List<Amount>() { Amount.Zero, item3, item2, item0, item1, Amount.Zero };
            var exp = new List<Amount>() { item3, item2, item1, item0, Amount.Zero, Amount.Zero };
            var act = inp.OrderByDescending(item => item).ToList();

            CollectionAssert.AreEqual(exp, act);
        }
开发者ID:Corniel,项目名称:Qowaiv,代码行数:13,代码来源:AmountTest.cs


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