本文整理汇总了C#中IReadOnlyList.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyList.Concat方法的具体用法?C# IReadOnlyList.Concat怎么用?C# IReadOnlyList.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyList
的用法示例。
在下文中一共展示了IReadOnlyList.Concat方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTagHelperDirectiveDescriptors
private static IEnumerable<TagHelperDirectiveDescriptor> GetTagHelperDirectiveDescriptors(
IReadOnlyList<CodeTree> inheritedCodeTrees,
IReadOnlyList<Chunk> defaultInheritedChunks)
{
var descriptors = new List<TagHelperDirectiveDescriptor>();
// For tag helpers, the @removeTagHelper only applies tag helpers that were added prior to it.
// Consequently we must visit tag helpers outside-in - furthest _GlobalImport first and nearest one last.
// This is different from the behavior of chunk merging where we visit the nearest one first and ignore
// chunks that were previously visited.
var chunksFromGlobalImports = inheritedCodeTrees
.Reverse()
.SelectMany(tree => tree.Chunks);
var chunksInOrder = defaultInheritedChunks.Concat(chunksFromGlobalImports);
foreach (var chunk in chunksInOrder)
{
// All TagHelperDirectiveDescriptors created here have undefined source locations because the source
// that created them is not in the same file.
var addTagHelperChunk = chunk as AddTagHelperChunk;
if (addTagHelperChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor(
addTagHelperChunk.LookupText,
SourceLocation.Undefined,
TagHelperDirectiveType.AddTagHelper);
descriptors.Add(descriptor);
continue;
}
var removeTagHelperChunk = chunk as RemoveTagHelperChunk;
if (removeTagHelperChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor(
removeTagHelperChunk.LookupText,
SourceLocation.Undefined,
TagHelperDirectiveType.RemoveTagHelper);
descriptors.Add(descriptor);
continue;
}
var tagHelperPrefixDirectiveChunk = chunk as TagHelperPrefixDirectiveChunk;
if (tagHelperPrefixDirectiveChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor(
tagHelperPrefixDirectiveChunk.Prefix,
SourceLocation.Undefined,
TagHelperDirectiveType.TagHelperPrefix);
descriptors.Add(descriptor);
}
}
return descriptors;
}
示例2: GetMissingLines
/// <summary>
/// This part of this splitter will remove line that already exsits and will split lines that are close to an exsiting line.
/// This can be used with both OSM lines and other parts of the same GPS trace.
/// The algorithm is faily simple -
/// Go over all the points in the given <see cref="gpxLine"/> and look for point that are close to <see cref="existingLineStrings"/>
/// </summary>
/// <param name="gpxLine">The line to manipulate</param>
/// <param name="existingLineStrings">The lines to test agains</param>
/// <param name="minimalMissingPartLength">The minimal length allowed to a trace that can be added</param>
/// <param name="closestPointTolerance">The distace of the closest point allowed</param>
/// <returns>a split line from the orignal line</returns>
public List<LineString> GetMissingLines(LineString gpxLine, IReadOnlyList<LineString> existingLineStrings, double minimalMissingPartLength, double closestPointTolerance)
{
var gpxSplit = new List<LineString>();
var waypointsGroup = new List<Coordinate>();
foreach (var coordinate in gpxLine.Coordinates)
{
if (waypointsGroup.Count > 0 && waypointsGroup.Last().Equals(coordinate))
{
continue;
}
if (IsCloseToALine(coordinate, existingLineStrings.Concat(gpxSplit).ToArray(), closestPointTolerance))
{
waypointsGroup.Add(coordinate);
AddLineString(gpxSplit, waypointsGroup.ToArray());
waypointsGroup = new List<Coordinate> { coordinate };
continue;
}
waypointsGroup.Add(coordinate);
}
AddLineString(gpxSplit, waypointsGroup.ToArray());
return gpxSplit.Where(l => l.Length > minimalMissingPartLength).ToList();
}
示例3: Execute
public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
return inputs.Concat(context.Execute(_modules));
}
示例4: Execute
public override IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
return inputs.Concat(base.Execute(inputs, context));
}
示例5: AddFlacExtensionWhenSupported
private static IReadOnlyList<string> AddFlacExtensionWhenSupported(IReadOnlyList<string> extensions)
{
if (IsFlacSupported)
{
return extensions.Concat(new[] { ".flac" }).ToArray();
}
return extensions;
}
示例6: GenerateMigration
public override string GenerateMigration(
string migrationNamespace,
string migrationName,
IReadOnlyList<MigrationOperation> upOperations,
IReadOnlyList<MigrationOperation> downOperations)
{
Check.NotEmpty(migrationNamespace, nameof(migrationNamespace));
Check.NotEmpty(migrationName, nameof(migrationName));
Check.NotNull(upOperations, nameof(upOperations));
Check.NotNull(downOperations, nameof(downOperations));
var builder = new IndentedStringBuilder();
var namespaces = new List<string>
{
"System",
"System.Collections.Generic",
"Microsoft.Data.Entity.Migrations"
};
namespaces.AddRange(GetNamespaces(upOperations.Concat(downOperations)));
foreach (var n in namespaces.Distinct())
{
builder
.Append("using ")
.Append(n)
.AppendLine(";");
}
builder
.AppendLine()
.Append("namespace ").AppendLine(_code.Namespace(migrationNamespace))
.AppendLine("{");
using (builder.Indent())
{
builder
.Append("public partial class ").Append(_code.Identifier(migrationName)).AppendLine(" : Migration")
.AppendLine("{");
using (builder.Indent())
{
builder
.AppendLine("protected override void Up(MigrationBuilder migrationBuilder)")
.AppendLine("{");
using (builder.Indent())
{
_operationGenerator.Generate("migrationBuilder", upOperations, builder);
}
builder
.AppendLine("}")
.AppendLine()
.AppendLine("protected override void Down(MigrationBuilder migrationBuilder)")
.AppendLine("{");
using (builder.Indent())
{
_operationGenerator.Generate("migrationBuilder", downOperations, builder);
}
builder.AppendLine("}");
}
builder.AppendLine("}");
}
builder.AppendLine("}");
return builder.ToString();
}
示例7: CollectionContains
private static bool CollectionContains(IReadOnlyList<IPosition> container, IReadOnlyList<IPosition> containee)
{
Contract.Requires(container != null);
Contract.Requires(containee != null);
Contract.RequiresForAll(container.Concat(containee), p => p is LinearPosition);
return //container.Count == containee.Count&&
container.Zip(containee, (a, b) => a.Contains(b)).All(); //default implementation. Can be improved
}
示例8: RuleStraightFlush
private void RuleStraightFlush(
ref double handStrength,
ref double handStrengthScore,
IReadOnlyList<int> clubCards,
IReadOnlyList<int> diamondCards,
IReadOnlyList<int> heartCards,
IReadOnlyList<int> spadeCards)
{
if (handStrength >= -1)
{
if (clubCards.Count >= 5)
{
if (clubCards[0] + 4 == clubCards[4])
{
handStrength = 8;
var max = clubCards.Concat(new[] {int.MinValue}).Max();
handStrengthScore = max / 4 + handStrength * 100;
AddWinningHandToList(handStrength, handStrengthScore);
FindWinningHand();
}
if (clubCards[0] == 0
&& clubCards[1] == 9
&& clubCards[2] == 10
&& clubCards[3] == 11
&& clubCards[0] + 12 == clubCards[4])
{
handStrength = 9;
var max = clubCards.Concat(new[] {int.MinValue}).Max();
handStrengthScore = max / 4 + handStrength * 100;
AddWinningHandToList(handStrength, handStrengthScore);
FindWinningHand();
}
}
if (diamondCards.Count >= 5)
{
if (diamondCards[0] + 4 == diamondCards[4])
{
handStrength = 8;
var max = diamondCards.Concat(new[] {int.MinValue}).Max();
handStrengthScore = max / 4 + handStrength * 100;
AddWinningHandToList(handStrength, handStrengthScore);
FindWinningHand();
}
if (diamondCards[0] == 0
&& diamondCards[1] == 9
&& diamondCards[2] == 10
&& diamondCards[3] == 11
&& diamondCards[0] + 12 == diamondCards[4])
{
handStrength = 9;
var max = diamondCards.Concat(new[] {int.MinValue}).Max();
handStrengthScore = max / 4 + handStrength * 100;
AddWinningHandToList(handStrength, handStrengthScore);
FindWinningHand();
}
}
if (heartCards.Count >= 5)
{
if (heartCards[0] + 4 == heartCards[4])
{
handStrength = 8;
var max = heartCards.Concat(new[] {int.MinValue}).Max();
handStrengthScore = max / 4 + handStrength * 100;
AddWinningHandToList(handStrength, handStrengthScore);
FindWinningHand();
}
if (heartCards[0] == 0
&& heartCards[1] == 9
&& heartCards[2] == 10
&& heartCards[3] == 11
&& heartCards[0] + 12 == heartCards[4])
{
handStrength = 9;
var max = heartCards.Concat(new[] {int.MinValue}).Max();
//.........这里部分代码省略.........
示例9: Execute
public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
IEnumerable<IDocument> documents = _predicate == null ? inputs : inputs.Where(x => _predicate(x, context));
return inputs.Concat(context.Execute(_modules, documents));
}
示例10: GetTagHelperDirectiveDescriptors
private static IEnumerable<TagHelperDirectiveDescriptor> GetTagHelperDirectiveDescriptors(
IReadOnlyList<ChunkTree> inheritedChunkTrees,
IReadOnlyList<Chunk> defaultInheritedChunks)
{
var descriptors = new List<TagHelperDirectiveDescriptor>();
var inheritedChunks = defaultInheritedChunks.Concat(inheritedChunkTrees.SelectMany(tree => tree.Chunks));
foreach (var chunk in inheritedChunks)
{
// All TagHelperDirectiveDescriptors created here have undefined source locations because the source
// that created them is not in the same file.
var addTagHelperChunk = chunk as AddTagHelperChunk;
if (addTagHelperChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor
{
DirectiveText = addTagHelperChunk.LookupText,
Location = chunk.Start,
DirectiveType = TagHelperDirectiveType.AddTagHelper
};
descriptors.Add(descriptor);
continue;
}
var removeTagHelperChunk = chunk as RemoveTagHelperChunk;
if (removeTagHelperChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor
{
DirectiveText = removeTagHelperChunk.LookupText,
Location = chunk.Start,
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
};
descriptors.Add(descriptor);
continue;
}
var tagHelperPrefixDirectiveChunk = chunk as TagHelperPrefixDirectiveChunk;
if (tagHelperPrefixDirectiveChunk != null)
{
var descriptor = new TagHelperDirectiveDescriptor
{
DirectiveText = tagHelperPrefixDirectiveChunk.Prefix,
Location = chunk.Start,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
};
descriptors.Add(descriptor);
}
}
return descriptors;
}
示例11: TraversalDataType
internal override IEnumerable<OverLoadTypeMatch> TraversalDataType(IReadOnlyList<TypeSymbol> pars)
{
var newpars = pars.Concat(Parameters).ToList();
return Next.TraversalDataType(newpars);
}
示例12: TraversalCall
internal override IEnumerable<OverLoadCallMatch> TraversalCall(IReadOnlyList<TypeSymbol> pars, IReadOnlyList<TypeSymbol> args)
{
var newpars = pars.Concat(Parameters).ToList();
return Next.TraversalCall(newpars, args);
}
示例13: VisitCall
private Expr VisitCall(MethodCallExpression methodCallExpression, IReadOnlyList<ParameterExpression> parameters)
{
var method = methodCallExpression.Method;
// TODO: Distinct
//var args = from arg in arr.Expressions select Visit(context, environment, arg, param);
//return context.MkDistinct(args.ToArray());
// bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
if (method.IsGenericMethod && method.GetGenericMethodDefinition() == typeof(Enumerable).GetMethods().Single(m => m.Name == "Any" && m.GetParameters().Length == 2))
{
var source = (MemberExpression)methodCallExpression.Arguments[0];
var predicate = (LambdaExpression)methodCallExpression.Arguments[1];
var sourceExpr = VisitMember(source, parameters);
var sourceExistConst = _context.MkConst("Any", ((ArraySort)sourceExpr.Sort).Domain);
LambdaParameterConstants.Add(predicate.Parameters[0].Name, sourceExistConst);
var predicateExpr = (BoolExpr)Visit(predicate.Body, parameters.Concat(predicate.Parameters).ToList());
var existsExpr = _context.MkExists(new[] { sourceExistConst },
_context.MkAnd((BoolExpr)_context.MkSetMembership(sourceExistConst, sourceExpr), predicateExpr)
);
return existsExpr;
}
// bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
if (method.IsGenericMethod && method.GetGenericMethodDefinition() == typeof(Enumerable).GetMethod("All"))
{
var source = (MemberExpression)methodCallExpression.Arguments[0];
var predicate = (LambdaExpression)methodCallExpression.Arguments[1];
var sourceExpr = VisitMember(source, parameters);
var sourceExistConst = _context.MkConst("All", ((ArraySort)sourceExpr.Sort).Domain);
LambdaParameterConstants.Add(predicate.Parameters[0].Name, sourceExistConst);
var predicateExpr = (BoolExpr)Visit(predicate.Body, parameters.Concat(predicate.Parameters).ToList());
var forAllExpr = _context.MkForall(new[] { sourceExistConst },
_context.MkOr(_context.MkNot((BoolExpr)_context.MkSetMembership(sourceExistConst, sourceExpr)), predicateExpr)
);
return forAllExpr;
}
throw new NotSupportedException("Unknown method call:" + method.ToString());
}