TakeExpression.cs 949 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Ant.Query.QueryExpressions;
  6. using Ant.Query.QueryState;
  7. using Ant.Query.Visitors;
  8. namespace Ant.Query.QueryExpressions
  9. {
  10. class TakeExpression : QueryExpression
  11. {
  12. int _count;
  13. public TakeExpression(Type elementType, QueryExpression prevExpression, int count)
  14. : base(QueryExpressionType.Take, elementType, prevExpression)
  15. {
  16. this.CheckInputCount(count);
  17. this._count = count;
  18. }
  19. public int Count
  20. {
  21. get { return this._count; }
  22. }
  23. void CheckInputCount(int count)
  24. {
  25. if (count < 0)
  26. {
  27. throw new ArgumentException("count 小于 0");
  28. }
  29. }
  30. public override T Accept<T>(QueryExpressionVisitor<T> visitor)
  31. {
  32. return visitor.Visit(this);
  33. }
  34. }
  35. }