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


C# ImmutableArray.Select方法代码示例

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


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

示例1: CreateFiles

		private static async Task<Solution> CreateFiles(Document document, SyntaxNode root,
			SemanticModel model, ImmutableArray<TypeToRemove> typesToRemove,
			Func<string, string> typeFolderGenerator,
			CancellationToken token)
		{
			var project = document.Project;
			var workspace = project.Solution.Workspace;

			project = ExtractTypesToFilesCodeRefactoringProvider.MoveTypeNodes(
				model, typesToRemove, typeFolderGenerator, project, token);

			var newRoot = root.RemoveNodes(
				typesToRemove.Select(_ => _.Declaration),
				SyntaxRemoveOptions.AddElasticMarker);

			var newSolution = project.Solution;
			var projectId = project.Id;
			newSolution = newSolution.WithDocumentSyntaxRoot(document.Id, newRoot);

			var newDocument = newSolution.GetProject(project.Id).GetDocument(document.Id);
			newRoot = await newDocument.GetSyntaxRootAsync(token);
			var newModel = await newDocument.GetSemanticModelAsync(token);
			var newUsings = newRoot.GenerateUsingDirectives(newModel);

			newRoot = newRoot.RemoveNodes(
				newRoot.DescendantNodes(_ => true).OfType<UsingDirectiveSyntax>(),
				SyntaxRemoveOptions.AddElasticMarker);

			newRoot = (newRoot as CompilationUnitSyntax)?.WithUsings(newUsings);
			return newSolution.WithDocumentSyntaxRoot(document.Id, newRoot);
		}
开发者ID:JasonBock,项目名称:CompilerAPIBook,代码行数:31,代码来源:ExtractTypesToFilesCodeRefactoringProvider.cs

示例2: CalculateMerkleRoot

        public static UInt256 CalculateMerkleRoot(ImmutableArray<Transaction> transactions, out ImmutableArray<ImmutableArray<byte>> merkleTree)
        {
            var workingMerkleTree = new List<ImmutableArray<byte>>();

            var hashes = transactions.Select(tx => tx.Hash.ToByteArray().ToImmutableArray()).ToList();

            workingMerkleTree.AddRange(hashes);
            while (hashes.Count > 1)
            {
                workingMerkleTree.AddRange(hashes);

                // ensure row is even length
                if (hashes.Count % 2 != 0)
                    hashes.Add(hashes.Last());

                // pair up hashes in row ({1, 2, 3, 4} into {{1, 2}, {3, 4}}) and then hash the pairs
                // the result is the next row, which will be half the size of the current row
                hashes =
                    Enumerable.Range(0, hashes.Count / 2)
                    .Select(i => hashes[i * 2].AddRange(hashes[i * 2 + 1]))
                    //.AsParallel().AsOrdered().WithExecutionMode(ParallelExecutionMode.ForceParallelism).WithDegreeOfParallelism(10)
                    .Select(pair => Crypto.DoubleSHA256(pair.ToArray()).ToImmutableArray())
                    .ToList();
            }
            Debug.Assert(hashes.Count == 1);

            merkleTree = workingMerkleTree.ToImmutableArray();
            return new UInt256(hashes[0].ToArray());
        }
开发者ID:holinov,项目名称:BitSharp,代码行数:29,代码来源:DataCalculator.cs

示例3: EncLocalSlotManager

 public EncLocalSlotManager(ImmutableArray<EncLocalInfo> previousLocals, GetPreviousLocalSlot getPreviousLocalSlot)
 {
     // Add placeholders for previous locals. The actual
     // identities are populated if/when the locals are reused.
     this.allLocals = new List<ILocalDefinition>(previousLocals.Select((info, index) => new SignatureOnlyLocalDefinition(info.Signature, index)));
     this.getPreviousLocalSlot = getPreviousLocalSlot;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:EncLocalSlotManager.cs

示例4: Create

        public static Block Create(BlockHeader header, ImmutableArray<DecodedTx> transactions)
        {
            var blockTxes = ImmutableArray.CreateRange(transactions.Select((tx, txIndex) =>
                new BlockTx(txIndex, tx)));

            return new Block(header, blockTxes);
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:7,代码来源:Block.cs

示例5: AllAttributed

		public void AllAttributed( ImmutableArray<Type> types )
		{
			Assert.Equal( 2, types.Length );
			var names = types.Select( type => type.FullName ).ToArray();
			Assert.Contains( "DragonSpark.Testing.Parts.PublicClass", names );
			Assert.Contains( "DragonSpark.Testing.Parts.NonPublicClass", names );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:PartsTests.cs

示例6: GenerateTypeParameterList

 public static TypeParameterListSyntax GenerateTypeParameterList(
     ImmutableArray<ITypeParameterSymbol> typeParameters, CodeGenerationOptions options)
 {
     return typeParameters.Length == 0
         ? null
         : SyntaxFactory.TypeParameterList(
             SyntaxFactory.SeparatedList(typeParameters.Select(t => GenerateTypeParameter(t, options))));
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:8,代码来源:TypeParameterGenerator.cs

示例7: SetupFilters

 protected override void SetupFilters(ImmutableArray<CompletionItemFilter> completionItemFilters)
 {
     // If more than one filter was provided, then present it to the user.
     if (_showFilters && Filters == null && completionItemFilters.Length > 1)
     {
         Filters = completionItemFilters.Select(f => new IntellisenseFilter2(this, f))
                                        .ToArray();
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:Roslyn15CompletionSet.cs

示例8: RunAsync

        public static async Task<Document> RunAsync(Document document, ImmutableArray<PatternReplacement> replacements)
        {
            if (document == null)
                throw new ArgumentNullException(nameof(document));

            var searches = replacements.Select(r => r.Search).ToImmutableArray();
            var searchResults = await PatternSearch.RunAsync(document, searches);
            return await RunAsync(document, replacements, searchResults);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:9,代码来源:PatternReplacement.RunAsync.cs

示例9: FixItemSpans

        private static ImmutableArray<CompletionItem> FixItemSpans(ImmutableArray<CompletionItem> items, TextSpan defaultSpan)
        {
            if (defaultSpan != default(TextSpan) && items.Any(i => i.Span == default(TextSpan)))
            {
                items = items.Select(i => i.Span == default(TextSpan) ? i.WithSpan(defaultSpan) : i).ToImmutableArray();
            }

            return items;
        }
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:9,代码来源:CompletionList.cs

示例10: Block

        public Block(BlockHeader header, ImmutableArray<BlockTx> blockTxes)
        {
            Header = header;

            BlockTxes = blockTxes;

            lazyTransactions = new Lazy<ImmutableArray<Transaction>>(() =>
                ImmutableArray.CreateRange(blockTxes.Select(x => x.Decode().Transaction)));
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:9,代码来源:Block.cs

示例11: CreatePagesFromFiles

        private ImmutableArray<PageDto> CreatePagesFromFiles(ImmutableArray<FileInfo> files)
        {
            return files.Select(file => new PageDto
            {
                Name = GetPageName(file),
                File = file,
                Text = ReadFileContents(file)

            }).ToImmutableArray();
        }
开发者ID:eaardal,项目名称:delbert,代码行数:10,代码来源:PageActor.cs

示例12: CompleteAllTodosReducer

 public static ImmutableArray<Todo> CompleteAllTodosReducer(ImmutableArray<Todo> previousState, CompleteAllTodosAction action)
 {
     return previousState
         .Select(x => new Todo
         {
             Id = x.Id,
             Text = x.Text,
             IsCompleted = action.IsCompleted
         })
         .ToImmutableArray();
 }
开发者ID:autechr3,项目名称:redux.NET,代码行数:11,代码来源:ApplicationReducer.cs

示例13: DetermineWebTechnology

        private static WebTechnology DetermineWebTechnology(ImmutableArray<INamedTypeSymbol> interfaces)
        {
            foreach (var fullName in interfaces.Select(i => i.ToString()))
            {
                if (fullName.StartsWith("System.Web.Http"))
                    return WebTechnology.WebApi;
                if (fullName.StartsWith("System.Web.Mvc"))
                    return WebTechnology.Mvc;
            }

            return WebTechnology.None;
        }
开发者ID:damieng,项目名称:CSharpCodeFixes,代码行数:12,代码来源:WrongAttributeOnControllerAnalyzer.cs

示例14: FixAllInDocumentAsync

            protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
            {
                if (diagnostics.IsEmpty)
                {
                    return null;
                }

                var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);

                var nodes = diagnostics.Select(diagnostic => syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true));

                return syntaxRoot.ReplaceNodes(nodes, (originalNode, rewrittenNode) => GetReplacementNode(rewrittenNode));
            }
开发者ID:NikolayIT,项目名称:StyleCopAnalyzers,代码行数:13,代码来源:SA1129CodeFixProvider.cs

示例15: GetFixedDocumentAsync

 private async static Task<SyntaxNode> GetFixedDocumentAsync(Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
 {
     var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
     var nodes = diagnostics.Select(d => root.FindNode(d.Location.SourceSpan)).Where(n => !n.IsMissing).Select(n => n.DescendantNodesAndSelf().OfType<MemberAccessExpressionSyntax>().First());
     var newRoot = root.ReplaceNodes(nodes, (original, rewritten) => original.WithAdditionalAnnotations(useEmptyStringAnnotation));
     while (true)
     {
         var annotatedNodes = newRoot.GetAnnotatedNodes(useEmptyStringAnnotation);
         var node = annotatedNodes.FirstOrDefault();
         if (node == null) break;
         var literal = (MemberAccessExpressionSyntax)node;
         newRoot = newRoot.ReplaceNode(literal, SyntaxFactory.ParseExpression("\"\"").WithLeadingTrivia(literal.GetLeadingTrivia()).WithTrailingTrivia(literal.GetTrailingTrivia()));
     }
     return newRoot;
 }
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:15,代码来源:UseEmptyStringCodeFixProviderAll.cs


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