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


C# ICollection.OrderBy方法代码示例

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


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

示例1: OrderDetailViewModel

 public OrderDetailViewModel(RequestDetail requestDetail, ICollection<StockInformation> stockInformations, ICollection<ApprovedDetail> approvedDetails, Forcasting forcasting, ConsumptionSetting consumptionSetting)
 {
     _requestDetail = requestDetail;
     _stockInformations = stockInformations;
     _approvedDetails = approvedDetails;
     _forcasting = forcasting;
     _consumptionSetting = consumptionSetting;
     _hasManyActivity = getActivityViewModels().Count > 2;
     _hasManyManufacturer = getManufacturerViewModels().Count > 2;
     _hasExpiryDatePreference = getExpiryDateViewModels().Count > 2;
     _hasPhysicalStorePreference = getPhysicalStoreViewModels().Count > 2;
     _allowAdd = _hasManyActivity || _hasManyManufacturer || _hasExpiryDatePreference || _hasPhysicalStorePreference;
     _allowRemove = RequestedQuantity == 0;
     if (_requestDetail.ActivityGroup == null)
     {
         var stockInformation = _stockInformations.OrderBy(s => s.ExpiryDate).FirstOrDefault();
         if (stockInformation != null)
         {
             _requestDetail.ActivityGroup = stockInformation.Activity;
         }
     }
     if (_requestDetail.IsFirstLoad)
     {
         if (_requestDetail.RequestedQuantity >= AvailableQuantity)
         {
             _requestDetail.ApprovedQuantity = AvailableQuantity;
         }
     }
 }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:29,代码来源:OrderDetailViewModel.cs

示例2: ScheduleFlights

 public void ScheduleFlights(ICollection<FlightModel> flights)
 {
     foreach (var flight in flights.OrderBy(f => f.Arrives))
     {
         ScheduleFlight(flight);
     }
 }
开发者ID:ryascl,项目名称:design-challenge-server-clr,代码行数:7,代码来源:Scheduler.cs

示例3: GetCardWithSuitThatEnemyDoesNotHave

        public Card GetCardWithSuitThatEnemyDoesNotHave(bool enemyHasATrumpCard, CardSuit trumpSuit, ICollection<Card> playerCards)
        {
            if (!enemyHasATrumpCard)
            {
                // In case the enemy does not have any trump cards and Stalker has a trump, he should throw a trump.
                var myTrumpCards = playerCards.Where(c => c.Suit == trumpSuit).ToList();
                if (myTrumpCards.Count() > 0)
                {
                    return myTrumpCards.OrderBy(c => c.GetValue()).LastOrDefault();
                }
            }

            var orderedCards = playerCards.OrderBy(c => c.GetValue());
            foreach (var card in orderedCards)
            {
                if (this.cardHolder.EnemyCards.All(c => c.Suit != card.Suit))
                {
                    if (enemyHasATrumpCard)
                    {
                        return playerCards.Where(c => c.Suit == card.Suit).OrderBy(c => c.GetValue()).FirstOrDefault();
                    }

                    return playerCards.Where(c => c.Suit == card.Suit).OrderByDescending(c => c.GetValue()).FirstOrDefault();
                }
            }

            return null;
        }
开发者ID:M-Yankov,项目名称:S.T.A.L.K.E.R,代码行数:28,代码来源:StalkerHelper.cs

示例4: DefaultRuntimeElementInfoFactoryDispatcher

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRuntimeElementInfoFactoryDispatcher" /> class.
        /// </summary>
        /// <param name="elementInfoExportFactories">The element information export factories.</param>
        protected DefaultRuntimeElementInfoFactoryDispatcher(ICollection<IExportFactory<IRuntimeElementInfoFactory, RuntimeElementInfoFactoryMetadata>> elementInfoExportFactories)
        {
            Contract.Requires(elementInfoExportFactories != null);

            this.elementInfoFactories = elementInfoExportFactories
                    .OrderBy(e => e.Metadata.ProcessingPriority)
                    .ToDictionary(e => e.CreateExport().Value, e => e.Metadata);
        }
开发者ID:movileanubeniamin,项目名称:kephas,代码行数:12,代码来源:DefaultRuntimeElementInfoFactoryDispatcher.cs

示例5: VotingSystem

 public VotingSystem(ICollection<Tag> tags)
 {
     int c = 0;
     this.tags = tags.OrderBy (x => x);
     foreach (Tag tag in this.tags) {
         dict.Add (tag, c);
         c++;
     }
     NumberOfTags = c;
 }
开发者ID:KommuSoft,项目名称:MLTag,代码行数:10,代码来源:VotingSystem.cs

示例6: DefaultSerializationService

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultSerializationService"/> class.
        /// </summary>
        /// <param name="serializerFactories">The serializer factories.</param>
        public DefaultSerializationService(ICollection<IExportFactory<ISerializer, SerializerMetadata>> serializerFactories)
        {
            Contract.Requires(serializerFactories != null);

            foreach (var factory in serializerFactories.OrderBy(f => f.Metadata.OverridePriority))
            {
                if (!this.serializerFactories.ContainsKey(factory.Metadata.FormatType))
                {
                    this.serializerFactories.Add(factory.Metadata.FormatType, factory);
                }
            }
        }
开发者ID:raimu,项目名称:kephas,代码行数:16,代码来源:DefaultSerializationService.cs

示例7: OrderItemsByDistance

 public static ICollection<Model.Node> OrderItemsByDistance(ICollection<Model.Node> nodes, Geopoint location) {
     if (nodes == null || location == null) {
         return nodes;
     }
     var point = Position.From(location);
     var elist = nodes.OrderBy(node => {
         double meters = Haversine.DistanceInMeters(point, new Position() { Latitude = node.lat, Longitude = node.lon });
         // update distance to show on map
         node.Distance = meters;
         return meters;
     });
     var list = elist.ToList();
     return list;
 }
开发者ID:Vedolin,项目名称:wheelmap-windows-app,代码行数:14,代码来源:NodesHelper.cs

示例8: PrintResults

        private static void PrintResults(TimeSpan totalTime, int parllelCount, ICollection<HttpResult> results)
        {
            var count = results.Count;
            var orderedResults = results.OrderBy(r => r.TimeTakenMs).ToList();

            Console.WriteLine("--------------------------------------------------");
            Console.WriteLine("Total time taken:    {0}", totalTime);
            Console.WriteLine("Total requests:      {0}", count);
            Console.WriteLine("Total errors:        {0}", results.Count(r => r.IsError));
            Console.WriteLine("Throughput QPS:      {0}", count/totalTime.TotalSeconds);
            Console.WriteLine("Parallel count:      {0}", parllelCount);
            Console.WriteLine("50th percentile:     {0}", orderedResults[(count * 10) / 20].TimeTakenMs);
            Console.WriteLine("85th percentile:     {0}", orderedResults[(count * 17) / 20].TimeTakenMs);
            Console.WriteLine("95th percentile:     {0}", orderedResults[(count * 19) / 20].TimeTakenMs);
            Console.WriteLine("--------------------------------------------------");
        }
开发者ID:donatasm,项目名称:WCF-Performance-Tuning,代码行数:16,代码来源:Program.cs

示例9: Set

 /// <summary>
 /// Resets strategy with new population of individuals.
 /// </summary>
 /// <param name="newPopulation">New population for strategy.</param>
 public void Set(ICollection<Individual> newPopulation)
 {
     if (newPopulation == null)
         throw new ArgumentException(nameof(newPopulation));
     if (newPopulation.Count == 0)
         throw new InvalidOperationException("Attempt to set empty population");
     var problem = newPopulation.First().Problem;
     var graph = newPopulation.First().Graph;
     if (newPopulation.Any(i => i.Graph != graph || i.Problem != problem))
         throw new AlgorithmException("Setting up new population", "Individuals in population represent either different graphs or different problems");
     _population = newPopulation;
     //In case is not SortedSet<T>
     if (!(_population is SortedSet<Individual>))
         _population = _population.OrderBy(p => p.SolutionFitness).ToList();
     InitializeRoulette();
 }
开发者ID:m-wilczynski,项目名称:Graphinder,代码行数:20,代码来源:RouletteStrategy.cs

示例10: DefaultRuntimeModelElementFactory

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRuntimeModelElementFactory" /> class.
        /// </summary>
        /// <param name="modelElementConstructors">The element information export factories.</param>
        /// <param name="modelElementConfigurators">The model element configurators.</param>
        public DefaultRuntimeModelElementFactory(
            ICollection<IExportFactory<IRuntimeModelElementConstructor, RuntimeModelElementConstructorMetadata>> modelElementConstructors,
            ICollection<IExportFactory<IRuntimeModelElementConfigurator, RuntimeModelElementConfiguratorMetadata>> modelElementConfigurators)
        {
            Contract.Requires(modelElementConstructors != null);

            this.modelElementConstructors = modelElementConstructors
                    .OrderBy(e => e.Metadata.ProcessingPriority)
                    .ToDictionary(e => e.CreateExport().Value, e => e.Metadata);

            this.modelElementConfigurators =
                (from cfg in modelElementConfigurators
                 group cfg by cfg.Metadata.RuntimeElementType
                 into cfgGroup select cfgGroup).ToDictionary(
                     g => g.Key.AsRuntimeTypeInfo(),
                     g => g.OrderBy(e => e.Metadata.ProcessingPriority).Select(e => e.CreateExport().Value).ToList());
        }
开发者ID:raimu,项目名称:kephas,代码行数:22,代码来源:DefaultRuntimeModelElementFactory.cs

示例11: CalculateTrend

        internal static StressTrend CalculateTrend(ICollection<HealthReport> healthReports)
        {

            var healthReportsOrdered = healthReports.OrderBy(hr => hr.Time);

            var firstHealthReport = healthReportsOrdered.First();

            var lastHealthReport = healthReportsOrdered.Last();

            if (firstHealthReport.Stress > lastHealthReport.Stress + StressOffset)
            {
                return StressTrend.Down;
            }
            if (firstHealthReport.Stress < lastHealthReport.Stress - StressOffset)
            {
                return StressTrend.Up;
            }

            return StressTrend.Equal;

        }
开发者ID:geekpivot,项目名称:HealthClinic.biz,代码行数:21,代码来源:StressCalculatorHelper.cs

示例12: ParsedFile

        public ParsedFile(string filePath, string hash, ICollection<ParsedElement> elements)
        {
            #region Argument Check

            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentException(
                    @"The value can be neither empty nor whitespace-only string nor null.",
                    nameof(filePath));
            }

            if (string.IsNullOrWhiteSpace(hash))
            {
                throw new ArgumentException(
                    @"The value can be neither empty nor whitespace-only string nor null.",
                    nameof(hash));
            }

            if (elements == null)
            {
                throw new ArgumentNullException(nameof(elements));
            }

            if (elements.Any(item => item == null))
            {
                throw new ArgumentException(@"The collection contains a null element.", nameof(elements));
            }

            #endregion

            FilePath = filePath;
            Hash = hash;

            Elements = elements
                .OrderBy(obj => obj.LineIndex)
                .ThenBy(obj => obj.GetType().FullName)
                .ToArray()
                .AsReadOnly();
        }
开发者ID:MyLoadTest,项目名称:LoadRunnerDocumentationAddin,代码行数:39,代码来源:ParsedFile.cs

示例13: VAtoFileMapping

        /// <summary>
        ///     Map an virtual address to the raw file address.
        /// </summary>
        /// <param name="VA">Virtual Address</param>
        /// <param name="sh">Section Headers</param>
        /// <returns>Raw file address.</returns>
        public static ulong VAtoFileMapping(this ulong VA, ICollection<IMAGE_SECTION_HEADER> sh)
        {
            VA -= 0x00400000;
            var sortedSt = sh.OrderBy(x => x.VirtualAddress).ToList();
            uint vOffset = 0, rOffset = 0;
            var secFound = false;
            for (var i = 0; i < sortedSt.Count - 1; i++)
            {
                if (sortedSt[i].VirtualAddress <= VA && sortedSt[i + 1].VirtualAddress > VA)
                {
                    vOffset = sortedSt[i].VirtualAddress;
                    rOffset = sortedSt[i].PointerToRawData;
                    secFound = true;
                    break;
                }
            }

            // try last section
            if (secFound == false)
            {
                if (VA >= sortedSt.Last().VirtualAddress &&
                    VA <= sortedSt.Last().VirtualSize + sortedSt.Last().VirtualAddress)
                {
                    vOffset = sortedSt.Last().VirtualAddress;
                    rOffset = sortedSt.Last().PointerToRawData;
                }
                else
                {
                    throw new Exception("Cannot find corresponding section.");
                }
            }

            return VA - vOffset + rOffset;
        }
开发者ID:secana,项目名称:PeNet,代码行数:40,代码来源:Utility.cs

示例14: EncodeRequestParameters

        /// <summary>
        /// Formats the list of request parameters into string a according
        /// to the requirements of oauth. The resulting string could be used
        /// in the Authorization header of the request.
        /// </summary>
        ///
        /// <remarks>
        ///   <para>
        ///     See http://dev.twitter.com/pages/auth#intro  for some
        ///     background.  The output of this is not suitable for signing.
        ///   </para>
        ///   <para>
        ///     There are 2 formats for specifying the list of oauth
        ///     parameters in the oauth spec: one suitable for signing, and
        ///     the other suitable for use within Authorization HTTP Headers.
        ///     This method emits a string suitable for the latter.
        ///   </para>
        /// </remarks>
        ///
        /// <param name="parameters">The Dictionary of
        /// parameters. It need not be sorted.</param>
        ///
        /// <returns>a string representing the parameters</returns>
        private static string EncodeRequestParameters(ICollection<KeyValuePair<String, String>> p)
        {
            var sb = new System.Text.StringBuilder();
            foreach (KeyValuePair<String, String> item in p.OrderBy(x => x.Key))
            {
                if (!String.IsNullOrEmpty(item.Value) &&
                    !item.Key.EndsWith("secret"))
                    sb.AppendFormat("oauth_{0}=\"{1}\", ",
                                    item.Key,
                                    UrlEncode(item.Value));
            }

            return sb.ToString().TrimEnd(' ').TrimEnd(',');
        }
开发者ID:nakijun,项目名称:daumapis,代码行数:37,代码来源:OAuth.cs

示例15: ReadTickets

        private static string ReadTickets(ICollection<Ticket> tickets)
        {
            var result = string.Join(" ", tickets.OrderBy(t => t));

            return result;
        }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:6,代码来源:TicketRepository.cs


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