本文整理汇总了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);
}
示例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());
}
示例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;
}
示例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);
}
示例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 );
}
示例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))));
}
示例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();
}
}
示例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);
}
示例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;
}
示例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)));
}
示例11: CreatePagesFromFiles
private ImmutableArray<PageDto> CreatePagesFromFiles(ImmutableArray<FileInfo> files)
{
return files.Select(file => new PageDto
{
Name = GetPageName(file),
File = file,
Text = ReadFileContents(file)
}).ToImmutableArray();
}
示例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();
}
示例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;
}
示例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));
}
示例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;
}