本文整理汇总了C#中ICollection.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.Skip方法的具体用法?C# ICollection.Skip怎么用?C# ICollection.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApiEnqueueBatch
/// <summary>
/// Please make sure what flatMessageData count <= <see cref="MAX_BATCH_SIZE" /> for preventing incomplete push for full batch collection
/// </summary>
/// <param name="flatMessageData"></param>
/// <returns></returns>
public ApiResult ApiEnqueueBatch(ICollection<Dictionary<string, object>> flatMessageData)
{
for (int i = 0; i < flatMessageData.Count; i += MAX_BATCH_SIZE)
{
ctx.PutBatch(flatMessageData.Skip(i).Take(MAX_BATCH_SIZE).ToArray());
ctx.WriteOppositeStateIfRequired(stream);
}
return ApiResult.OK;
}
示例2: HandleDoubleWordSurnamePrefix
private static void HandleDoubleWordSurnamePrefix(NameParts result, ICollection<string> parts)
{
if (!IsTwoPartSurnamePrefix(parts))
{
return;
}
result.Surname = String.Join(" ", parts.Skip(parts.Count - 2).Take(2)) + " " + result.Surname;
result.MiddleName = parts.Count == 2 ? null : String.Join(" ", parts.Take(parts.Count - 2));
}
示例3: Replace
public static void Replace(this Collection<Instruction> collection, Instruction instruction, ICollection<Instruction> instructions)
{
var newInstruction = instructions.First();
instruction.Operand = newInstruction.Operand;
instruction.OpCode = newInstruction.OpCode;
var indexOf = collection.IndexOf(instruction);
foreach (var instruction1 in instructions.Skip(1))
{
collection.Insert(indexOf+1, instruction1);
indexOf++;
}
}
示例4: Buildup
protected internal void Buildup(AggregateInfo aggregateInfo, ICollection<Event> replayEvents)
{
var creationEvent = replayEvents.First();
var changeEvents = replayEvents.Skip(1);
var aggregate = blank(aggregateInfo.Type);
aggregateInfo.Instance = aggregate;
aggregateInfo.Lifestate = AggregateLifestate.Building;
construct(aggregateInfo, creationEvent);
replay(changeEvents, aggregate);
aggregateInfo.Lifestate = AggregateLifestate.Live;
}
示例5: SortAndCount
public static int[] SortAndCount(ICollection<int> unsortedArray, out long inversionCount)
{
if (unsortedArray.Count <= 1)
{
inversionCount = 0;
return unsortedArray.ToArray();
}
int length = unsortedArray.Count;
int half = length/2;
long leftInversionCount, rightInversionCount, splitInversionCount;
var left = SortAndCount(unsortedArray.Take(half).ToArray(), out leftInversionCount);
var right = SortAndCount(unsortedArray.Skip(half).Take(length - half).ToArray(), out rightInversionCount);
var sortedArray = MergeAndCount(length, left, right, out splitInversionCount);
inversionCount = leftInversionCount + rightInversionCount + splitInversionCount;
return sortedArray;
}
示例6: GenerateDelete
public string GenerateDelete(ICollection<DbDeleteCommandTree> commandTrees, string rowsAffectedParameter)
{
DebugCheck.NotNull(commandTrees);
List<SqlParameter> _;
var sql = new StringBuilder();
sql.AppendLine(
DmlSqlGenerator.GenerateDeleteSql(
commandTrees.First(),
_sqlGenerator,
out _));
sql.AppendLine();
foreach (var commandTree in commandTrees.Skip(1))
{
sql.AppendLine(
DmlSqlGenerator.GenerateDeleteSql(
commandTree,
_sqlGenerator,
out _));
sql.AppendLine("AND @@ROWCOUNT > 0");
sql.AppendLine();
}
AppendSetRowsAffected(sql, rowsAffectedParameter);
return sql.ToString().TrimEnd();
}
示例7: GenerateUpdate
public string GenerateUpdate(ICollection<DbUpdateCommandTree> commandTrees, string rowsAffectedParameter)
{
DebugCheck.NotNull(commandTrees);
if (!commandTrees.Any())
{
return null;
}
List<SqlParameter> _;
var sql = new StringBuilder();
sql.AppendLine(
DmlSqlGenerator.GenerateUpdateSql(
commandTrees.First(),
_sqlGenerator,
out _,
generateReturningSql: false));
foreach (var commandTree in commandTrees.Skip(1))
{
sql.Append(
DmlSqlGenerator.GenerateUpdateSql(
commandTree,
_sqlGenerator,
out _,
generateReturningSql: false));
sql.AppendLine("AND @@ROWCOUNT > 0");
sql.AppendLine();
}
var returningCommandTrees
= commandTrees
.Where(ct => ct.Returning != null)
.ToList();
if (returningCommandTrees.Any())
{
var returningSelectSqlGenerator = new ReturningSelectSqlGenerator();
foreach (var commandTree in returningCommandTrees)
{
commandTree.Target.Expression.Accept(returningSelectSqlGenerator);
commandTree.Returning.Accept(returningSelectSqlGenerator);
commandTree.Predicate.Accept(returningSelectSqlGenerator);
}
sql.AppendLine(returningSelectSqlGenerator.Sql);
sql.AppendLine();
}
AppendSetRowsAffected(sql, rowsAffectedParameter);
return sql.ToString().TrimEnd();
}
示例8: ExtractValue
protected virtual string ExtractValue(ICollection<string> tokens, object obj)
{
if (obj == null)
{
return "null";
}
if (!tokens.Any())
{
if (obj is Item)
{
return ((Item) obj).Name;
}
return obj.ToString();
}
var tokenPattern = tokens.FirstOrDefault();
if (string.IsNullOrEmpty(tokenPattern))
{
return string.Empty;
}
object value = string.Empty;
// this is a property
if (tokenPattern.StartsWith("@@"))
{
tokenPattern = tokenPattern.Replace("@@", string.Empty);
value = this.GetProperty(tokenPattern, obj);
}
// this is a field
else if (tokenPattern.StartsWith("@"))
{
tokenPattern = tokenPattern.Replace("@", string.Empty);
value = this.GetItemField(tokenPattern, obj);
}
var remainingTokens = tokens.Skip(1).ToArray();
if (value is Item)
{
return ExtractValue(remainingTokens, value as Item);
}
if (!(value is string))
{
return this.ExtractValue(remainingTokens, value);
}
return value.ToString();
}
示例9: InnerAllCombinations
private ICollection<string> InnerAllCombinations(ICollection<int> sequenceSections, int remainingLength)
{
var spareSquares = remainingLength - this.MinSequenceLength(sequenceSections);
if (sequenceSections.Count == 0)
{
return new[] { new string('0', spareSquares) };
}
var ending = "0";
if (sequenceSections.Count == 1)
{
ending = string.Empty;
}
var ret = new List<string>();
for (int i = 0; i <= spareSquares; i++)
{
var stub = new string('0', i) + new string('1', sequenceSections.First()) + ending;
ret.AddRange(this.InnerAllCombinations(sequenceSections.Skip(1).ToList(), remainingLength - stub.Length).Select(s => stub + s));
}
return ret;
}
示例10: BitToByte
protected byte[] BitToByte(List<byte> bytes, ref ICollection<int> bitHolder)
{
while (bitHolder.Count >= 8)
{
var sequence = bitHolder.Take(8);
var builder = new StringBuilder();
foreach (var x in sequence)
{
builder.Append(x.ToString());
}
bytes.Add(Convert.ToByte(builder.ToString(), 2));
bitHolder = bitHolder.Skip(8).ToList();
}
return bytes.ToArray();
}
示例11: Sort
public IEnumerable<String> Sort(
ICollection<String> strings)
{
var result = new List<String>(strings.Count);
result.AddRange(strings.Skip(28).Take(11));
result.AddRange(strings.Skip(15).Take(24));
result.AddRange(strings.Skip(53).Take(01));
result.AddRange(strings.Skip(43).Take(11));
result.AddRange(strings.Skip(39).Take(04));
result.AddRange(strings.Skip(01).Take(27));
result.AddRange(strings.Skip(75).Take(02));
result.AddRange(strings.Skip(54).Take(21));
return result;
}
示例12: ConvertNegativeLongs
private static byte[] ConvertNegativeLongs(ICollection<byte> output, long value)
{
if (value >= sbyte.MinValue)
return new[] { output.Last() };
if (value >= -32768)
return output.Skip(output.Count - 2).ToArray();
if (value >= -2147483648)
return output.Skip(output.Count - 4).ToArray();
return output.ToArray();
}
示例13: ExtractCommand
private static string ExtractCommand(ICollection<string> args, out string[] remaining)
{
remaining = args.Count <= 1 ? new string[0] : args.Skip(1).ToArray();
return (args.FirstOrDefault() ?? string.Empty).ToLowerInvariant();
}
示例14: GetBlogPostPageViewModel
private BlogPostPageViewModel GetBlogPostPageViewModel(ICollection<PostEntity> posts, int? pageNumber)
{
var pgNumber = pageNumber ?? 1;
var totalItems = GetPageCount(posts.Count);
var blogPostModel = GetBlogPostPageModel(pgNumber, totalItems);
blogPostModel.Posts = posts.Skip((pgNumber - 1) * _postsPerPage)
.Take(_postsPerPage)
.ToList();
blogPostModel.BlogName = SettingsRepository.BlogName;
blogPostModel.BlogCaption = SettingsRepository.BlogCaption;
blogPostModel.CurrentPageNumber = pageNumber.HasValue ? pageNumber.Value : 1;
return blogPostModel;
}
示例15: GenerateInsert
public string GenerateInsert(ICollection<DbInsertCommandTree> commandTrees)
{
DebugCheck.NotNull(commandTrees);
var sql = new StringBuilder();
List<SqlParameter> _;
var firstCommandTree = commandTrees.First();
sql.Append(
DmlSqlGenerator.GenerateInsertSql(
firstCommandTree,
_sqlGenerator,
out _,
generateReturningSql: false,
createParameters: false));
sql.AppendLine();
var firstTable
= (EntityType)((DbScanExpression)firstCommandTree.Target.Expression).Target.ElementType;
sql.Append(IntroduceRequiredLocalVariables(firstTable, firstCommandTree));
foreach (var commandTree in commandTrees.Skip(1))
{
sql.Append(
DmlSqlGenerator.GenerateInsertSql(
commandTree,
_sqlGenerator,
out _,
generateReturningSql: false,
createParameters: false));
sql.AppendLine();
}
var returningCommandTrees
= commandTrees
.Where(ct => ct.Returning != null)
.ToList();
if (returningCommandTrees.Any())
{
var returningSelectSqlGenerator = new ReturningSelectSqlGenerator();
foreach (var commandTree in returningCommandTrees)
{
commandTree.Target.Expression.Accept(returningSelectSqlGenerator);
commandTree.Returning.Accept(returningSelectSqlGenerator);
}
foreach (var keyProperty in firstTable.KeyProperties)
{
var parameterReference
= firstCommandTree
.SetClauses
.Cast<DbSetClause>()
.Where(sc => ((DbPropertyExpression)sc.Property).Property == keyProperty)
.Select(sc => sc.Value)
.SingleOrDefault()
?? keyProperty.TypeUsage.Parameter(keyProperty.Name);
firstCommandTree
.Target
.Variable
.Property(keyProperty)
.Equal(parameterReference)
.Accept(returningSelectSqlGenerator);
}
sql.Append(returningSelectSqlGenerator.Sql);
}
return sql.ToString().TrimEnd();
}