Sort.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using FastReport.Utils;
  5. namespace FastReport
  6. {
  7. /// <summary>
  8. /// Represents a sort condition used in the <see cref="DataBand.Sort"/>.
  9. /// </summary>
  10. public class Sort : IFRSerializable
  11. {
  12. private string expression;
  13. private bool descending;
  14. /// <summary>
  15. /// Gets or sets an expression used to sort data band rows.
  16. /// </summary>
  17. /// <remarks>
  18. /// This property can contain any valid expression.
  19. /// </remarks>
  20. public string Expression
  21. {
  22. get { return expression; }
  23. set { expression = value; }
  24. }
  25. /// <summary>
  26. /// Gets or sets a value indicating that sort must be performed in descending order.
  27. /// </summary>
  28. public bool Descending
  29. {
  30. get { return descending; }
  31. set { descending = value; }
  32. }
  33. /// <summary>
  34. /// Serializes the class.
  35. /// </summary>
  36. /// <param name="writer">Writer object.</param>
  37. /// <remarks>
  38. /// This method is for internal use only.
  39. /// </remarks>
  40. public void Serialize(FRWriter writer)
  41. {
  42. writer.ItemName = "Sort";
  43. writer.WriteStr("Expression", Expression);
  44. if (Descending)
  45. writer.WriteBool("Descending", Descending);
  46. }
  47. /// <summary>
  48. /// Deserializes the class.
  49. /// </summary>
  50. /// <param name="reader">Reader object.</param>
  51. /// <remarks>
  52. /// This method is for internal use only.
  53. /// </remarks>
  54. public void Deserialize(FRReader reader)
  55. {
  56. reader.ReadProperties(this);
  57. }
  58. /// <summary>
  59. /// Initializes a new instance of the <see cref="Sort"/> class with default settings.
  60. /// </summary>
  61. public Sort() : this("")
  62. {
  63. }
  64. /// <summary>
  65. /// Initializes a new instance of the <see cref="Sort"/> class with specified expression.
  66. /// </summary>
  67. public Sort(string expression) : this(expression, false)
  68. {
  69. }
  70. /// <summary>
  71. /// Initializes a new instance of the <see cref="Sort"/> class with specified expression and sort order.
  72. /// </summary>
  73. public Sort(string expression, bool descending)
  74. {
  75. this.expression = expression;
  76. this.descending = descending;
  77. }
  78. }
  79. }