本文整理汇总了C#中ImmutableArray.First方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.First方法的具体用法?C# ImmutableArray.First怎么用?C# ImmutableArray.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.First方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompositeText
public CompositeText(ImmutableArray<SourceText> texts)
: base(checksumAlgorithm: texts[0].ChecksumAlgorithm)
{
Debug.Assert(!texts.IsDefaultOrEmpty);
Debug.Assert(texts.All(t => texts.First().Encoding == t.Encoding && texts.First().ChecksumAlgorithm == t.ChecksumAlgorithm));
_texts = texts;
int len = 0;
foreach (var text in texts)
{
len += text.Length;
}
_length = len;
}
示例2: CompleteTodoReducer
public static ImmutableArray<Todo> CompleteTodoReducer(ImmutableArray<Todo> previousState, CompleteTodoAction action)
{
var todoToEdit = previousState.First(todo => todo.Id == action.TodoId);
return previousState
.Replace(todoToEdit, new Todo
{
Id = todoToEdit.Id,
Text = todoToEdit.Text,
IsCompleted = !todoToEdit.IsCompleted
});
}
示例3: CompositeText
public CompositeText(ImmutableArray<SourceText> texts)
{
Debug.Assert(!texts.IsDefaultOrEmpty);
Debug.Assert(texts.All(t => texts.First().Encoding == t.Encoding));
this.texts = texts;
int len = 0;
foreach (var text in texts)
{
len += text.Length;
}
this.length = len;
}
示例4: GetOverloadCount
private static int GetOverloadCount(ImmutableArray<ISymbol> symbolGroup)
{
return symbolGroup.Select(s => s.OriginalDefinition)
.Where(s => !s.Equals(symbolGroup.First().OriginalDefinition))
.Where(s => s is IMethodSymbol || s.IsIndexer())
.Count();
}
开发者ID:jkotas,项目名称:roslyn,代码行数:7,代码来源:AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs
示例5: GetUsingActions
private async Task<IEnumerable<CodeActionOperation>> GetUsingActions(ICodeActionProvider codeActionProvider,
ImmutableArray<Diagnostic> pointDiagnostics, string actionPrefix)
{
var actions = new List<CodeAction>();
var context = new CodeFixContext(_document, pointDiagnostics.First().Location.SourceSpan, pointDiagnostics, (a, d) => actions.Add(a), CancellationToken.None);
var providers = codeActionProvider.CodeFixes;
//Disable await warning since we dont need the result of the call. Else we need to use a throwaway variable.
#pragma warning disable 4014
foreach (var provider in providers)
{
provider.RegisterCodeFixesAsync(context);
}
#pragma warning restore 4014
var tasks = actions.Where(a => a.Title.StartsWith(actionPrefix))
.Select(async a => await a.GetOperationsAsync(CancellationToken.None)).ToList();
return (await Task.WhenAll(tasks)).SelectMany(x => x);
}
示例6: DeleteTodoReducer
public static ImmutableArray<Todo> DeleteTodoReducer(ImmutableArray<Todo> previousState, DeleteTodoAction action)
{
var todoToDelete = previousState.First(todo => todo.Id == action.TodoId);
return previousState.Remove(todoToDelete);
}
示例7: CreateInvocableCompletionGroup
private static CompletionItem CreateInvocableCompletionGroup(ImmutableArray<Symbol> symbols)
{
var symbol = symbols.First();
var first = CreateSymbolCompletion(symbol);
var numberOfOverloads = symbols.Count() - 1;
var displayText = first.DisplayText;
var insertionText = first.InsertionText;
var description = string.Format(Resources.CompletionItemWithOverloads, first.Description, numberOfOverloads);
if (!string.IsNullOrEmpty(symbol.Documentation))
description += Environment.NewLine + symbol.Documentation;
var glyph = first.Glyph;
return new CompletionItem(displayText, insertionText, description, glyph, symbol);
}
示例8: CreateSymbolCompletionGroup
private static CompletionItem CreateSymbolCompletionGroup(string name, ImmutableArray<Symbol> symbols)
{
var multiple = symbols.Skip(1).Any();
if (!multiple)
return CreateSymbolCompletion(symbols.First());
var hasNonInvocables = symbols.Any(s => !(s is InvocableSymbol));
if (!hasNonInvocables)
return CreateInvocableCompletionGroup(symbols);
var displayText = name;
var insertionText = name;
var sb = new StringBuilder();
sb.Append(Resources.AmbiguousName);
foreach (var symbol in symbols)
{
sb.AppendLine();
sb.Append(@" ");
sb.Append(symbol);
}
var description = sb.ToString();
return new CompletionItem(displayText, insertionText, description, Glyph.CompletionWarning);
}
示例9: GetFigureFromPoints
private static PathFigure GetFigureFromPoints(ImmutableArray<PortablePoint> points)
{
var figure = new PathFigure();
figure.StartPoint = points.First().ToPoint();
foreach (var segment in points.Skip(1).Select(p => new LineSegment() { Point = p.ToPoint() }))
{
figure.Segments.Add(segment);
}
return figure;
}