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


C# ICollection.SelectMany方法代码示例

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


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

示例1: GetNumberInstrumentChanges

        private static int GetNumberInstrumentChanges(ICollection<Song> songs)
        {
            var numMembers = songs.SelectMany(x => x.SongMemberInstruments)
                .GroupBy(x => x.Member)
                .Count();
            
            var instrumentationCount = songs.SelectMany(x => x.SongMemberInstruments)
                .GroupBy(x => x.Instrument)
                .Select(x => x.Key)
                .Count();

            return (instrumentationCount - numMembers);
        }
开发者ID:jyuma,项目名称:SetGenerator,代码行数:13,代码来源:SetlistHelper.cs

示例2: GetLayout

        private string GetLayout(ContentTypeDefinition contentTypeDefinition, ICollection<Section> data) {
            //check field valid
            if (contentTypeDefinition.Parts.Any()) {
                var part = contentTypeDefinition.Parts.First(x => x.PartDefinition.Name == contentTypeDefinition.Name);
                var partFields = part.PartDefinition.Fields.ToList();
                var fields = data.SelectMany(x => x.Rows)
                    .SelectMany(x => x.Columns)
                    .Where(x => x.Field != null)
                    .Select(x => x.Field).ToList();
                if (partFields.Any(f => f.Settings.ContainsKey(AlwaysInLayoutKey)
                                        && bool.Parse(f.Settings[AlwaysInLayoutKey])
                                        && !fields.Select(x => x.FieldName).Contains(f.Name))) {
                    return string.Empty;
                }
                foreach (var field in fields) {
                    if (partFields.Any(x => x.Name == field.FieldName)) {
                        field.IsValid = true;
                    }
                    else if (contentTypeDefinition.Parts.Any(x => x.PartDefinition.Name == field.FieldName)) {
                        field.IsValid = true;
                    }
                }
            }

            ViewDataDictionary viewData = new ViewDataDictionary();
            viewData.Add("Layout", data);
            string layout = _templateViewService
                .RenderView("Coevery.FormDesigner", "FormTemplate", "FormDesignerLayout", viewData);
            return layout;
        }
开发者ID:wezmag,项目名称:Coevery,代码行数:30,代码来源:LayoutController.cs

示例3: Validate

        public static bool Validate(object instance, ICollection<ValidationResult> validationResults, Action<string> onErrorsChanged)
        {
            var propertiesThatHadErrors = validationResults.SelectMany(v => v.MemberNames).Distinct().ToHashSet();

            validationResults.Clear();

            var validationResult = Validator.TryValidateObject(instance, new ValidationContext(instance),
                                                               validationResults, true);

            var propertiesThatHaveErrors = validationResults.SelectMany(v => v.MemberNames).Distinct().ToHashSet();

            foreach (var property in propertiesThatHaveErrors.Concat(propertiesThatHadErrors).Distinct())
            {
                onErrorsChanged(property);
            }

            return validationResult;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:18,代码来源:Validation.cs

示例4: GetQuotation

        public QuotationResult GetQuotation(ICollection<BrokerDefinition> brokerDefinitions, TransactionType transactionType, int amount)
        {
            if(brokerDefinitions == null)
            {
                throw new ArgumentNullException("Broker Definitions cannot be null");
            }
            if(amount <= 0)
            {
                throw new ArgumentOutOfRangeException("Amount must be greater than 0");
            }

            ICollection<BrokerIdWithAmount> result = new List<BrokerIdWithAmount>();
            decimal calculatedAmount = 0m;
            int processedAmount = 0;
            List<TresholdWithBroker> tresholds = brokerDefinitions.SelectMany(
                    broker => broker.Tresholds.Select(treshold =>
                            new TresholdWithBroker(treshold, broker))
                ).ToList();

            // other way around for sales? See readme
            tresholds = tresholds.OrderBy(t => t.CalculateRatePerCoin(transactionType)).ToList();

            while (processedAmount < amount)
            {
                int amountLeft = amount - processedAmount;

                var treshold = tresholds.FirstOrDefault(t => t.Treshold.From <= amountLeft);
                if(treshold == null)
                {
                    return new QuotationResult
                    {
                        CanProcess = false
                    };
                }

                int amountInThisTreshold = (int)Math.Min(amountLeft, treshold.Treshold.To);

                result.Add(new BrokerIdWithAmount()
                {
                    Amount = amountInThisTreshold,
                    BrokerId = treshold.Broker.BrokerId
                });
                processedAmount += amountInThisTreshold;
                calculatedAmount += amountInThisTreshold * treshold.CalculateRatePerCoin(transactionType);

                // in case given broker is maxed out
                tresholds = tresholds.Where(t => t.Broker != treshold.Broker).ToList();
            }

            return new QuotationResult() {
                Result = result,
                TotalAmount = calculatedAmount,
                CanProcess = true
            };
        }
开发者ID:GrzePie,项目名称:Investobank,代码行数:55,代码来源:TheBestQuotationAlgorithm.cs

示例5: DeleteProductsOrderDetails

        public static void DeleteProductsOrderDetails(ICollection<Product> products, NorthwindDbContext db, bool doCommit = true)
        {
            IEnumerable<Order_Detail> details = products.SelectMany(x => x.Order_Details);

            if (details != null || details.Count() > 0)
            {
                db.Order_Details.RemoveRange(details);
            }

            if (doCommit)
            {
                db.SaveChanges();
            }
        }
开发者ID:JarvisJ,项目名称:North-PM,代码行数:14,代码来源:SupplierAPIService.cs

示例6: AnalyzeProjectAsync

        public async Task AnalyzeProjectAsync(ICollection<Project> projects)
        {
            var buildSucceeded = await _builder.BuildAsync(projects);

            if (!buildSucceeded)
            {
                throw new PortabilityAnalyzerException(LocalizedStrings.UnableToBuildProject);
            }

            // TODO: Add option to include everything in output, not just build artifacts
            var targetAssemblies = projects.SelectMany(p => p.GetAssemblyPaths()).ToList();

            var result = await _analyzer.WriteAnalysisReportsAsync(targetAssemblies, _reportWriter, true);

            var sourceItems = await Task.Run(() => _sourceLineMapper.GetSourceInfo(targetAssemblies, result));

            DisplaySourceItemsInErrorList(sourceItems, projects);
        }
开发者ID:AlexGhiondea,项目名称:dotnet-apiport,代码行数:18,代码来源:ProjectAnalyzer.cs

示例7: GetTrustedSigners

        /// <summary>
        /// Gets the trusted signers.
        /// </summary>
        /// <param name="keys">The keys.</param>
        /// <param name="identityProvider">The identity provider.</param>
        /// <returns>List of trusted certificate signers.</returns>
        public static IEnumerable<AsymmetricAlgorithm> GetTrustedSigners(ICollection<KeyDescriptor> keys, IdentityProvider identityProvider)
        {
            if (keys == null) {
                throw new ArgumentNullException("keys");
            }

            foreach (var clause in keys.SelectMany(k => k.KeyInfo.Items.AsEnumerable().Cast<KeyInfoClause>())) {
                // Check certificate specifications
                if (clause is KeyInfoX509Data) {
                    var cert = XmlSignatureUtils.GetCertificateFromKeyInfo((KeyInfoX509Data)clause);
                    if (!CertificateSatisfiesSpecifications(identityProvider, cert)) {
                        continue;
                    }
                }

                var key = XmlSignatureUtils.ExtractKey(clause);
                yield return key;
            }
        }
开发者ID:jbparker,项目名称:SAML2,代码行数:25,代码来源:Utility.cs

示例8: FindGoodNodeNames

 public static IEnumerable<string> FindGoodNodeNames(ICollection<CstNode> uppermosts) {
     var name2Count = new Dictionary<string, int>();
     var name2Ids = new Dictionary<string, HashSet<string>>();
     var candidates = uppermosts.SelectMany(
             e => e.DescendantsOfSingleAndSelf());
     foreach (var e in candidates) {
         if (name2Count.ContainsKey(e.Name)) {
             name2Count[e.Name] += 1;
             name2Ids[e.Name].Add(e.NameAndTokenWithId());
         } else {
             name2Count[e.Name] = 1;
             name2Ids[e.Name] = new HashSet<string> {
                 e.NameAndTokenWithId()
             };
         }
     }
     return uppermosts.Select(
             e => e.DescendantsOfSingleAndSelf()
                     .Select(e2 => e2.Name)
                     .MaxElementOrDefault(
                             name => (name2Count[name] << 8) + name2Ids[name].Count));
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:22,代码来源:LearningExperimentUtil.cs

示例9: ResolveParameterSetAmbiguityBasedOnMandatoryParameters

        internal static int ResolveParameterSetAmbiguityBasedOnMandatoryParameters(
            Dictionary<String, MergedCompiledCommandParameter> boundParameters,
            ICollection<MergedCompiledCommandParameter> unboundParameters,
            MergedCommandParameterMetadata bindableParameters,
            ref uint _currentParameterSetFlag,
            Cmdlet command
            )
        {
            uint remainingParameterSetsWithNoMandatoryUnboundParameters = _currentParameterSetFlag;

            IEnumerable<ParameterSetSpecificMetadata> allParameterSetMetadatas = boundParameters.Values
                .Concat(unboundParameters)
                .SelectMany(p => p.Parameter.ParameterSetData.Values);
            uint allParameterSetFlags = 0;
            foreach (ParameterSetSpecificMetadata parameterSetMetadata in allParameterSetMetadatas)
            {
                allParameterSetFlags |= parameterSetMetadata.ParameterSetFlag;
            }
            remainingParameterSetsWithNoMandatoryUnboundParameters &= allParameterSetFlags;

            Diagnostics.Assert(
                ValidParameterSetCount(remainingParameterSetsWithNoMandatoryUnboundParameters) > 1,
                "This method should only be called when there is an ambiguity wrt parameter sets");

            IEnumerable<ParameterSetSpecificMetadata> parameterSetMetadatasForUnboundMandatoryParameters = unboundParameters
                .SelectMany(p => p.Parameter.ParameterSetData.Values)
                .Where(p => p.IsMandatory);
            foreach (ParameterSetSpecificMetadata parameterSetMetadata in parameterSetMetadatasForUnboundMandatoryParameters)
            {
                remainingParameterSetsWithNoMandatoryUnboundParameters &= (~parameterSetMetadata.ParameterSetFlag);
            }

            int finalParameterSetCount = ValidParameterSetCount(remainingParameterSetsWithNoMandatoryUnboundParameters);
            if (finalParameterSetCount == 1)
            {
                _currentParameterSetFlag = remainingParameterSetsWithNoMandatoryUnboundParameters;

                if (command != null)
                {
                    string currentParameterSetName = bindableParameters.GetParameterSetName(_currentParameterSetFlag);
                    command.SetParameterSetName(currentParameterSetName);
                }
                return finalParameterSetCount;
            }
            return -1;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:46,代码来源:CmdletParameterBinderController.cs

示例10: CreateTextOccurenceSearcher

 public IDomainSpecificSearcher CreateTextOccurenceSearcher(ICollection<IDeclaredElement> elements)
 {
     return new NitraTextOccurenceSearcher(elements.SelectMany(GetAllPossibleWordsInFile));
 }
开发者ID:hwwang,项目名称:Nitra,代码行数:4,代码来源:NitraSearcherFactory.cs

示例11: VerifyAllCSpacePropertiesAreMapped

        private static void VerifyAllCSpacePropertiesAreMapped(
            ICollection<StorageEntityTypeMapping> entityTypeMappings, IEnumerable<EdmProperty> properties,
            IList<EdmProperty> propertyPath)
        {
            DebugCheck.NotNull(entityTypeMappings);

            var entityType = entityTypeMappings.First().EntityType;

            foreach (var property in properties)
            {
                propertyPath.Add(property);

                if (property.IsComplexType)
                {
                    VerifyAllCSpacePropertiesAreMapped(
                        entityTypeMappings,
                        property.ComplexType.Properties,
                        propertyPath);
                }
                else if (!entityTypeMappings.SelectMany(etm => etm.MappingFragments)
                              .SelectMany(mf => mf.ColumnMappings)
                              .Any(pm => pm.PropertyPath.SequenceEqual(propertyPath))
                         && !entityType.Abstract)
                {
                    throw Error.InvalidEntitySplittingProperties(entityType.Name);
                }

                propertyPath.Remove(property);
            }
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:30,代码来源:EntityTypeConfiguration.cs

示例12: CreateGraph

 private Graph<Value> CreateGraph(ICollection<Value> values)
 {
     var allParents = values.SelectMany(v => v.Parents).Distinct();
     var nonParents = values.Except(allParents);
     var fakeRoot = new Value(null);
     fakeRoot.AddParents(nonParents);
     var builder = new GraphBuilder<Value>(v => v.Parents);
     return builder.Build(fakeRoot);
 }
开发者ID:provegard,项目名称:testness,代码行数:9,代码来源:MethodValueTracker.cs

示例13: LearnWithoutClearing

 private LearningResult LearnWithoutClearing(
         ICollection<string> seedPaths, LearningExperiment exp,
         ICollection<string> projectPaths) {
     var writer =
             CreateWriter(exp.GetType().Name + "_learn_" + projectPaths.Count() + ".csv");
     var codePaths = projectPaths.SelectMany(
             projectPath => Directory.GetFiles(
                     projectPath, SearchPattern, SearchOption.AllDirectories)
             ).ToList();
     writer.Write(DateTime.Now);
     writer.Write(",");
     writer.Write(projectPaths.First());
     writer.Write(",");
     var learningResult = exp.Learn(seedPaths, codePaths, SearchPattern, writer);
     var classificationResult = learningResult.ClassificationResult;
     writer.Write(classificationResult.WrongElementCount);
     writer.Write(",");
     writer.Write(classificationResult.WrongVectorCount);
     writer.Write(",");
     writer.WriteLine();
     writer.Flush();
     if (classificationResult.WrongVectorCount > 0) {
         PrintWrongResults(classificationResult, learningResult);
     }
     var seedWriter =
             CreateWriter(exp.GetType().Name + "_seed_" + projectPaths.Count() + ".txt");
     WriteSeedVectors(seedWriter, learningResult);
     var featureWriter =
             CreateWriter(exp.GetType().Name + "_feature_" + projectPaths.Count() + ".txt");
     WriteFeatureStrings(featureWriter, learningResult.Classifier,
             learningResult.FeatureEncoder, learningResult.EncodingResult);
     return learningResult;
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:33,代码来源:Experiment.cs

示例14: SynchronizeCollections

 Task SynchronizeCollections(ICollection<Game> games) {
     var contents = games.SelectMany(x => x.Contents).OfType<NetworkContent>().Distinct().ToArray();
     return
         _networkContentSyncer.SyncCollections(games.SelectMany(x => x.SubscribedCollections).ToArray(),
             contents, false);
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:6,代码来源:SetupGameStuff.cs

示例15: _addWordsAsWordChain

 private void _addWordsAsWordChain(IEnumerable<IPPI.SentenceWord> ippiWords, ICollection<SentenceWordChain> wordsChains, SentenceWordType wordsType)
 {
     wordsChains.Add(_toWordChain(ippiWords));
     wordsChains.SelectMany(chain => chain.Words).ForEach(word => word.Type = wordsType);
 }
开发者ID:Ogonik,项目名称:LWS,代码行数:5,代码来源:ComparisonModelBuilder.cs


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