本文整理汇总了C#中ReadOnlyCollection.Take方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.Take方法的具体用法?C# ReadOnlyCollection.Take怎么用?C# ReadOnlyCollection.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.Take方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitFieldDeclarations
protected ReadOnlyCollection<FieldDeclaration> VisitFieldDeclarations(ReadOnlyCollection<FieldDeclaration> fields)
{
List<FieldDeclaration> alternate = null;
for (int i = 0, n = fields.Count; i < n; i++)
{
FieldDeclaration field = fields[i];
Expression e = this.Visit(field.Expression);
if (alternate == null && e != field.Expression)
{
alternate = fields.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(new FieldDeclaration(field.Name, e));
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
return fields;
}
示例2: VisitFieldDeclarationList
protected virtual ReadOnlyCollection<FieldDeclaration> VisitFieldDeclarationList(ReadOnlyCollection<FieldDeclaration> fields)
{
if (fields == null)
return fields;
List<FieldDeclaration> alternate = null;
for (int i = 0, n = fields.Count; i < n; i++)
{
var f = fields[i];
var e = Visit(f.Expression);
if (f.Expression != e && alternate == null)
alternate = fields.Take(i).ToList();
if (alternate != null)
alternate.Add(new FieldDeclaration(f.Name, e));
}
if (alternate != null)
return alternate.AsReadOnly();
return fields;
}
示例3: VisitOrderBy
protected ReadOnlyCollection<OrderExpression> VisitOrderBy(ReadOnlyCollection<OrderExpression> orderBys)
{
if (orderBys != null)
{
List<OrderExpression> alternate = null;
for (int i = 0, n = orderBys.Count; i < n; i++)
{
OrderExpression expr = orderBys[i];
Expression e = this.Visit(expr.Expression);
if (alternate == null && e != expr.Expression)
alternate = orderBys.Take(i).ToList();
if (alternate != null)
alternate.Add(new OrderExpression(expr.OrderType, e));
}
if (alternate != null)
return alternate.AsReadOnly();
}
return orderBys;
}
示例4: VisitColumnDeclarations
protected ReadOnlyCollection<ColumnDeclaration> VisitColumnDeclarations(
ReadOnlyCollection<ColumnDeclaration> nodes)
{
List<ColumnDeclaration> alternate = null;
for (Int32 i = 0, n = nodes.Count; i < n; i++)
{
ColumnDeclaration column = nodes[i];
Expression e = Visit(column.Expression);
if (alternate == null && e != column.Expression)
{
alternate = nodes.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(new ColumnDeclaration(column.Name, e));
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
return nodes;
}
示例5: VisitOrderBy
protected virtual ReadOnlyCollection<OrderExpression> VisitOrderBy(ReadOnlyCollection<OrderExpression> expressions)
{
if (expressions != null)
{
List<OrderExpression> alternate = null;
for (int i = 0, n = expressions.Count; i < n; i++)
{
OrderExpression expr = expressions[i];
Expression e = this.Visit(expr.Expression);
if (alternate == null && e != expr.Expression)
{
alternate = expressions.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(new OrderExpression(expr.OrderType, e));
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
}
return expressions;
}
示例6: VisitColumnDeclarations
protected virtual ReadOnlyCollection<ColumnDeclaration> VisitColumnDeclarations(ReadOnlyCollection<ColumnDeclaration> columns)
{
List<ColumnDeclaration> alternate = null;
for (int i = 0, n = columns.Count; i < n; i++)
{
ColumnDeclaration column = columns[i];
Expression e = this.Visit(column.Expression);
if (alternate == null && e != column.Expression)
{
alternate = columns.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(new ColumnDeclaration(column.Name, e));
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
return columns;
}
示例7: VisitVariableDeclarations
protected virtual ReadOnlyCollection<DbVariableDeclaration> VisitVariableDeclarations(
ReadOnlyCollection<DbVariableDeclaration> decls)
{
List<DbVariableDeclaration> alternate = null;
for (int i = 0, n = decls.Count; i < n; i++)
{
DbVariableDeclaration decl = decls[i];
Expression e = Visit(decl.Expression);
if (alternate == null && e != decl.Expression)
alternate = decls.Take(i).ToList();
if (alternate != null)
alternate.Add(new DbVariableDeclaration(decl.Name, decl.DbType, e));
}
if (alternate != null)
return alternate.AsReadOnly();
return decls;
}
示例8: VisitColumnAssignments
protected virtual ReadOnlyCollection<DbColumnAssignment> VisitColumnAssignments(
ReadOnlyCollection<DbColumnAssignment> assignments)
{
List<DbColumnAssignment> alternate = null;
for (int i = 0, n = assignments.Count; i < n; i++)
{
DbColumnAssignment assignment = VisitColumnAssignment(assignments[i]);
if (alternate == null && assignment != assignments[i])
alternate = assignments.Take(i).ToList();
if (alternate != null)
alternate.Add(assignment);
}
if (alternate != null)
return alternate.AsReadOnly();
return assignments;
}
示例9: VisitFieldAssignments
protected virtual ReadOnlyCollection<FieldAssignment> VisitFieldAssignments(ReadOnlyCollection<FieldAssignment> assignments)
{
List<FieldAssignment> alternate = null;
for (int i = 0, n = assignments.Count; i < n; i++)
{
FieldAssignment assignment = this.VisitFieldAssignment(assignments[i]);
if (alternate == null && assignment != assignments[i])
{
alternate = assignments.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(assignment);
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
return assignments;
}
示例10: VisitOrderBy
protected ReadOnlyCollection<OrderByExpression> VisitOrderBy(ReadOnlyCollection<OrderByExpression> nodes)
{
if (nodes != null)
{
List<OrderByExpression> alternate = null;
for (Int32 i = 0, n = nodes.Count; i < n; i++)
{
OrderByExpression expr = nodes[i];
Expression e = Visit(expr.Expression);
if (alternate == null && e != expr.Expression)
{
alternate = nodes.Take(i).ToList();
}
if (alternate != null)
{
alternate.Add(new OrderByExpression(e, expr.Direction));
}
}
if (alternate != null)
{
return alternate.AsReadOnly();
}
}
return nodes;
}