SqlToken.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Collections.Generic;
  2. namespace FastReport.FastQueryBuilder
  3. {
  4. internal enum SqlTokenType
  5. {
  6. Keyword,
  7. Punctuation,
  8. Name,
  9. Operation,
  10. EOF
  11. }
  12. internal class SqlToken
  13. {
  14. #region Private Fields
  15. private string lowerText;
  16. private int position;
  17. private string text;
  18. private SqlTokenType type;
  19. #endregion Private Fields
  20. #region Public Properties
  21. public string LowerText
  22. {
  23. get
  24. {
  25. if (lowerText == null)
  26. lowerText = text.ToLower();
  27. return lowerText;
  28. }
  29. }
  30. public int Position
  31. {
  32. get { return position; }
  33. }
  34. public string Text
  35. {
  36. get
  37. {
  38. return text;
  39. }
  40. }
  41. public SqlTokenType Type
  42. {
  43. get { return type; }
  44. }
  45. #endregion Public Properties
  46. #region Public Constructors
  47. public SqlToken(SqlTokenType type, string text, int position)
  48. {
  49. this.type = type;
  50. this.text = text;
  51. this.position = position;
  52. }
  53. public override bool Equals(object obj)
  54. {
  55. SqlToken token = obj as SqlToken;
  56. return token != null &&
  57. LowerText == token.LowerText &&
  58. Type == token.Type;
  59. }
  60. public override int GetHashCode()
  61. {
  62. int hashCode = -969693818;
  63. hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(LowerText);
  64. hashCode = hashCode * -1521134295 + Type.GetHashCode();
  65. return hashCode;
  66. }
  67. #endregion Public Constructors
  68. }
  69. }