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


C# List.Any方法代码示例

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


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

示例1: Session

        public Session(Timer timer, IEnumerable<string> portStrings)
        {
            List<string> textPortStrings = new List<string>();
            List<string> yarpPortStrings = new List<string>();
            List<string> rosPortStrings = new List<string>();

            foreach (string portString in portStrings)
            {
                if (portString.Length < 2) throw new InvalidOperationException("\"" + portString + "\" is not a valid port string");

                switch (portString.Substring(0, 2))
                {
                    case "t:": textPortStrings.Add(portString.Substring(2)); break;
                    case "y:": yarpPortStrings.Add(portString.Substring(2)); break;
                    case "r:": rosPortStrings.Add(portString.Substring(2)); break;
                    default: throw new InvalidOperationException("\"" + portString + "\" is not a valid port string");
                }
            }

            if (yarpPortStrings.Any()) this.yarpNetwork = new YarpNetwork();
            if (rosPortStrings.Any()) this.rosNetwork = new RosNetwork();

            List<Receiver> receivers = new List<Receiver>();
            foreach (string portString in textPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = name == "-" ? new TextReaderPort() : new TextReaderPort(name);
                receivers.Add(new Receiver(port, timer, portString));
            }
            foreach (string portString in yarpPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = new YarpReaderPort(name, yarpNetwork);
                receivers.Add(new Receiver(port, timer, portString));
            }
            foreach (string portString in rosPortStrings)
            {
                string name = portString.Split(':').First();
                Port port = new RosPort(name, rosNetwork);
                receivers.Add(new Receiver(port, timer, portString));
            }
            this.receivers = receivers;

            if (receivers.Count(receiver => receiver.HasTimer) > 1) throw new ArgumentException("More than one timer stream was found.");

            this.capture = new Capture
            (
                from receiver in receivers
                select new PortData(receiver.PortName, receiver.PortStreams)
            );
        }
开发者ID:SolomonBier,项目名称:streamvis,代码行数:51,代码来源:Session.cs

示例2: SearchForIssues

        public string SearchForIssues(string[] tags)
        {
            if (tags.Length <= 0)
            {
                return Constants.NoTagsProvidedMsg;
            }

            var issues = new List<Issue>();
            foreach (var t in tags)
            {
                issues.AddRange(this.Data.IssuesByTag[t]);
            }

            if (!issues.Any())
            {
                return Constants.NoIssuesMatchingTheTagProvidedMsg;
            }

            var uniqueIssues = issues.Distinct();
            if (!uniqueIssues.Any())
            {
                return Constants.NoIssuesMsg;
            }

            return string.Join(Environment.NewLine, uniqueIssues.OrderByDescending(x => x.Priority).ThenBy(x => x.Title));
        }
开发者ID:AngataHristov,项目名称:High-Quality-Code,代码行数:26,代码来源:IssueTracker.cs

示例3: SearchForIssues

        public string SearchForIssues(string[] tags)
        {
            // If there are no tags provided, the action returns There are no tags provided
            if (tags.Length < 0)
            {
                return "There are no tags provided";
            }

            var issues = new List<Issue>();
            foreach (var tag in tags)
            {
                issues.AddRange(this.Data.Tag_Issues[tag]);
            }

            // If there are no matching issues, the action returns There are no issues matching the tags provided
            if (!issues.Any())
            {
                return "There are no issues matching the tags provided";
            }

            // If an issue matches several tags, it is included only once in the search results. 
            var uniqueIssues = issues.Distinct();

            // In case of success, the action returns the issues sorted by priority (in descending order) first, and by title (in alphabetical order) next. 
            return string.Join(
                Environment.NewLine,
                uniqueIssues.OrderByDescending(x => x.Priority).ThenBy(x => x.Title));
        }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:28,代码来源:IssueTracker.cs

示例4: ComputeOutputTax

        /// <summary>
        /// Output VAT is the value added tax you calculate and charge on your own sales of goods and services
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="quantity"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public List<KeyValuePair<int, decimal>> ComputeOutputTax(int customerId, int itemId, decimal quantity, decimal amount, decimal discount)
        {
            decimal taxAmount = 0, amountXquantity = 0, discountAmount = 0, subTotalAmount = 0;

            var item = _itemRepo.GetById(itemId);
            var customer = _customerRepo.GetById(customerId);
            var taxes = new List<KeyValuePair<int, decimal>>();

            amountXquantity = amount * quantity;

            if(discount > 0)
                discountAmount = (discount / 100) * amountXquantity;

            subTotalAmount = amountXquantity - discountAmount;

            if (item.ItemTaxGroup != null)
            {
                foreach (var tax in item.ItemTaxGroup.ItemTaxGroupTax)
                {
                    if (!tax.IsExempt)
                    {
                        taxAmount = subTotalAmount - (subTotalAmount / (1 + (tax.Tax.Rate / 100)));
                        taxes.Add(new KeyValuePair<int, decimal>(tax.Id, taxAmount));
                    }
                }
            }

            if(customer.TaxGroup != null)
            {
                foreach (var tax in customer.TaxGroup.TaxGroupTax)
                {
                    if (taxes.Any(t => t.Key == tax.Id))
                        continue;

                    taxAmount = subTotalAmount - (subTotalAmount / (1 + (tax.Tax.Rate / 100)));
                    taxes.Add(new KeyValuePair<int, decimal>(tax.Id, taxAmount));
                }
            }

            return taxes;
        }
开发者ID:umerlone,项目名称:accountgo,代码行数:48,代码来源:FinancialService.cs

示例5: SearchForIssues

        public string SearchForIssues(string[] tags) {
            if (tags.Length <= 0)
            {
                return "There are no tags provided";
            }

            var issues = new List<Issue>();
            foreach (var tag in tags)
            {
                issues.AddRange(this.Data.IssuesByTag[tag]);
            }
            if (!issues.Any())
            {
                return "There are no issues matching the tags provided";
            }

            var distinctIssues = issues.Distinct();
            if (!distinctIssues.Any())
            {
                return "No issues";
            }

            var orderedDistinctIssues =
                distinctIssues
                .OrderByDescending(i => i.Priority)
                .ThenBy(i => i.Title)
                .Select(i => i.ToString());
            return string.Join(Environment.NewLine, orderedDistinctIssues);
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:29,代码来源:BuhtigIssueTracker.cs

示例6: SearchForIssues

        public string SearchForIssues(string[] strings) {
            if (strings.Length < 0)
                return "There are no tags provided";

            var i = new List<Problem>();
            foreach (var t in strings)
                i.AddRange(Data.issues4[t]);
            if (!i.Any())
                return "There are no issues matching the tags provided";
            var newi = i.Distinct();
            if (!newi.Any())
            {
                return "No issues";
            }
            return string.Join(Environment.NewLine, newi.OrderByDescending(x => x.Priority).ThenBy(x => x.Title).Select(x => string.Empty));
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:16,代码来源:moreStuff.cs

示例7: UpdateAllParohiis

 private void UpdateAllParohiis(List<long> collectionFromCifFields)
 {
     if (collectionFromCifFields != null)
     {
         if (collectionFromCifFields.Any())
         {
             foreach (var cif in collectionFromCifFields)
             {
                 UpdateSingleParohiiCif(cif);
             }
         }
     }
 }
开发者ID:Nikolay-D,项目名称:RomanianClientAscontEparhii,代码行数:13,代码来源:TablesController.cs


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