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


C# IReadOnlyList.GroupBy方法代码示例

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


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

示例1: LoadChangeScripts

        private void LoadChangeScripts()
        {
            var scripts = new DirectoryInfo(path);
            Files = scripts.GetFiles("*.sql", SearchOption.AllDirectories)
                           .Select(x => ScriptFile.Load(x))
                           .OrderBy(x => x)
                           .ToList();

            var duplicates = Files.GroupBy(x => x.FileNameHash).Where(x => x.Count() > 1);
            if (duplicates.Any())
            {
                var sb = new StringBuilder();
                foreach (var duplicate in duplicates)
                {
                    sb.AppendLine($"Duplicate Filename Detected: \"{duplicate.First().FileName}\"");
                    foreach (var file in duplicate)
                    {
                        sb.AppendLine($"\t\"{file.FilePath}\"");
                    }
                }
                sb.AppendLine();
                sb.AppendLine("All filenames must be unique. Including those in separate subdirectories.");
                throw new Exception(sb.ToString());
            }
        }
开发者ID:jdaigle,项目名称:Horton,代码行数:25,代码来源:FileLoader.cs

示例2: DeclarationFinder

        public DeclarationFinder(
            IReadOnlyList<Declaration> declarations, 
            IEnumerable<CommentNode> comments,
            IEnumerable<IAnnotation> annotations)
        {
            _comments = comments.GroupBy(node => node.QualifiedSelection.QualifiedName)
                .ToDictionary(grouping => grouping.Key, grouping => grouping.ToArray());
            _annotations = annotations.GroupBy(node => node.QualifiedSelection.QualifiedName)
                .ToDictionary(grouping => grouping.Key, grouping => grouping.ToArray());

            _declarationsByName = declarations.GroupBy(declaration => new
                {
                    IdentifierName = declaration.Project != null && 
                        declaration.DeclarationType == DeclarationType.Project
                            ? declaration.Project.Name
                            : declaration.IdentifierName
                })
                .ToDictionary(grouping => grouping.Key.IdentifierName, grouping => grouping.ToArray());
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:19,代码来源:DeclarationFinder.cs

示例3: LoadTypes

        private void LoadTypes()
        {
            m_allTypes = new LiftedList<TypeDefinition>(
                MetadataTable.TypeDef.RowCount(m_peFile),
                index => m_peFile.GetRow(new ZeroBasedIndex(index), MetadataTable.TypeDef),
                pRow => new TypeDefinition((TypeDefRow*)pRow, this),
                () => m_peFile.IsDisposed
            );

            var nestedTypes = new LiftedValueTypeList<NestedTypeInfo>(
                MetadataTable.NestedClass.RowCount(m_peFile),
                index=>m_peFile.GetRow(new ZeroBasedIndex(index), MetadataTable.NestedClass),
                x=> {
                    var pRow = (NestedClassRow*) x;
                    return new NestedTypeInfo(
                        m_allTypes[((ZeroBasedIndex)(pRow->GetNestedClass(m_peFile))).Value],
                        m_allTypes[((ZeroBasedIndex)(pRow->GetEnclosingClass(m_peFile))).Value]
                    );
                },
                ()=>m_peFile.IsDisposed
            );

            var enclosingTypes = nestedTypes.Select(x => x.NestedType.DeclaringType = x.EnclosingType).ToHashSet();
            m_allTypes.GroupBy(x => x.DeclaringType).ForEach(
                x => (x.Key ?? (IMutableTypeContainer)this).Types = x.ToList().AsReadOnly()
            );
            m_allTypes.Where(
                x => !enclosingTypes.Contains(x)
            ).ForEach(
                (IMutableTypeContainer x) => x.Types = new List<TypeDefinition>().AsReadOnly()
            );
        }
开发者ID:scottwis,项目名称:tiny,代码行数:32,代码来源:Module.cs

示例4: RemoveInheritedInverseNavigations

        private IReadOnlyList<RelationshipCandidate> RemoveInheritedInverseNavigations(
            IReadOnlyList<RelationshipCandidate> relationshipCandidates)
        {
            var relationshipCandidatesByRoot = relationshipCandidates.GroupBy(r => r.TargetTypeBuilder.Metadata.RootType())
                .ToDictionary(g => g.Key, g => g.ToList());
            foreach (var relationshipCandidatesHierarchy in relationshipCandidatesByRoot.Values)
            {
                var filteredRelationshipCandidates = new HashSet<RelationshipCandidate>();
                foreach (var relationshipCandidate in relationshipCandidatesHierarchy)
                {
                    RemoveInheritedInverseNavigations(
                        relationshipCandidate, relationshipCandidatesHierarchy, filteredRelationshipCandidates);
                }
            }

            return relationshipCandidates;
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:17,代码来源:RelationshipDiscoveryConvention.cs

示例5: GetDuplicatedVersion

        private int? GetDuplicatedVersion(IReadOnlyList<Migration> migrations)
        {
            int duplicatedVersion = migrations
                .GroupBy(x => x.Version)
                .Where(x => x.Count() > 1)
                .Select(x => x.Key)
                .FirstOrDefault();

            return duplicatedVersion == 0 ? (int?)null : duplicatedVersion;
        }
开发者ID:vkhorikov,项目名称:DatabaseUpgradeTool,代码行数:10,代码来源:VersionManager.cs


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