IdCollection.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System.Collections;
  2. using IwbZero.ToolCommon.StringModel;
  3. namespace IwbZero.IwbBase
  4. {
  5. public class IdCollection : CollectionBase
  6. {
  7. // Methods
  8. public int Add(IIwbId poObject)
  9. {
  10. return InnerList.Add(poObject);
  11. }
  12. public bool Contains(IIwbId poObject)
  13. {
  14. return (IndexOf(poObject) >= 0);
  15. }
  16. public bool Contains(string pcId)
  17. {
  18. return (IndexOf(pcId) >= 0);
  19. }
  20. public int IndexOf(IIwbId poObject)
  21. {
  22. return IndexOf(poObject.Id);
  23. }
  24. public int IndexOf(string pcId)
  25. {
  26. pcId = pcId.UAndT();
  27. for (int i = 0; i < InnerList.Count; i++)
  28. {
  29. IIwbId id = (IIwbId)InnerList[i];
  30. if (id.Id.UAndT() == pcId)
  31. {
  32. return i;
  33. }
  34. }
  35. return -1;
  36. }
  37. public void Remove(IIwbId poObject)
  38. {
  39. InnerList.Remove(poObject);
  40. }
  41. public void Remove(string pcId)
  42. {
  43. int index = IndexOf(pcId);
  44. if (index >= 0)
  45. {
  46. RemoveAt(index);
  47. }
  48. }
  49. // Properties
  50. public IIwbId this[int piIndex]
  51. {
  52. get
  53. {
  54. if ((piIndex < InnerList.Count) && (piIndex >= 0))
  55. {
  56. return (IIwbId)InnerList[piIndex];
  57. }
  58. return null;
  59. }
  60. }
  61. public IIwbId this[string pcId]
  62. {
  63. get
  64. {
  65. int index = IndexOf(pcId);
  66. if (index >= 0)
  67. {
  68. return (IIwbId)InnerList[index];
  69. }
  70. return null;
  71. }
  72. }
  73. }
  74. }