DataSourceInternal.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: DataSourceInternal
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: [email protected]
  8. * Implementation: Yes
  9. * Status: 100%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.Collections;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. internal class DataSourceInternal : ICollection, IEnumerable
  20. {
  21. private int itemCount;
  22. public DataSourceInternal(int itemCount)
  23. {
  24. this.itemCount = itemCount;
  25. }
  26. public int Count
  27. {
  28. get
  29. {
  30. return itemCount;
  31. }
  32. }
  33. public bool IsReadOnly
  34. {
  35. get
  36. {
  37. return false;
  38. }
  39. }
  40. public bool IsSynchronized
  41. {
  42. get
  43. {
  44. return false;
  45. }
  46. }
  47. public object SyncRoot
  48. {
  49. get
  50. {
  51. return this;
  52. }
  53. }
  54. public void CopyTo(Array array, int index)
  55. {
  56. IEnumerator e = GetEnumerator();
  57. while(e.MoveNext())
  58. {
  59. array.SetValue(e.Current, index);
  60. index++;
  61. }
  62. }
  63. public IEnumerator GetEnumerator()
  64. {
  65. return new DataSourceEnumeratorInternal(itemCount);
  66. }
  67. private class DataSourceEnumeratorInternal : IEnumerator
  68. {
  69. private int count;
  70. private int index;
  71. public DataSourceEnumeratorInternal(int count)
  72. {
  73. this.count = count;
  74. this.index = -1;
  75. }
  76. public bool MoveNext()
  77. {
  78. index++;
  79. return (index < count);
  80. }
  81. public object Current
  82. {
  83. get
  84. {
  85. return null;
  86. }
  87. }
  88. public void Reset()
  89. {
  90. this.index = -1;
  91. }
  92. }
  93. }
  94. }