RelationCollection.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Collections;
  5. using FastReport.Utils;
  6. namespace FastReport.Data
  7. {
  8. /// <summary>
  9. /// Represents the collection of <see cref="Relation"/> objects.
  10. /// </summary>
  11. public class RelationCollection : FRCollectionBase
  12. {
  13. /// <summary>
  14. /// Gets or sets a relation.
  15. /// </summary>
  16. /// <param name="index">The index of a relation in this collection.</param>
  17. /// <returns>The relation with specified index.</returns>
  18. public Relation this[int index]
  19. {
  20. get { return List[index] as Relation; }
  21. set { List[index] = value; }
  22. }
  23. /// <summary>
  24. /// Finds a relation by its name.
  25. /// </summary>
  26. /// <param name="name">The name of a relation.</param>
  27. /// <returns>The <see cref="Relation"/> object if found; otherwise <b>null</b>.</returns>
  28. public Relation FindByName(string name)
  29. {
  30. foreach (Relation c in this)
  31. {
  32. if (c.Name == name)
  33. return c;
  34. }
  35. return null;
  36. }
  37. /// <summary>
  38. /// Finds a relation by its alias.
  39. /// </summary>
  40. /// <param name="alias">The alias of a relation.</param>
  41. /// <returns>The <see cref="Relation"/> object if found; otherwise <b>null</b>.</returns>
  42. public Relation FindByAlias(string alias)
  43. {
  44. foreach (Relation c in this)
  45. {
  46. if (c.Alias == alias)
  47. return c;
  48. }
  49. return null;
  50. }
  51. /// <summary>
  52. /// Finds a relation that is equal to specified one.
  53. /// </summary>
  54. /// <param name="rel">Another relation to compare with.</param>
  55. /// <returns>The <see cref="Relation"/> object if found; otherwise <b>null</b>.</returns>
  56. public Relation FindEqual(Relation rel)
  57. {
  58. foreach (Relation c in this)
  59. {
  60. if (c.Equals(rel))
  61. return c;
  62. }
  63. return null;
  64. }
  65. /// <summary>
  66. /// Initializes a new instance of the <see cref="RelationCollection"/> class with default settings.
  67. /// </summary>
  68. /// <param name="owner">The owner of this collection.</param>
  69. public RelationCollection(Base owner) : base(owner)
  70. {
  71. }
  72. }
  73. }