OidEnumerator.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // OidEnumerator.cs - System.Security.Cryptography.OidEnumerator
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if NET_1_2
  10. using System;
  11. using System.Collections;
  12. namespace System.Security.Cryptography {
  13. // Note: Match the definition of framework version 1.2.3400.0 on http://longhorn.msdn.microsoft.com
  14. public sealed class OidEnumerator : IEnumerator {
  15. private OidCollection _collection;
  16. private int _position;
  17. // note: couldn't reuse the IEnumerator from ArrayList because
  18. // it doesn't throw the same exceptions
  19. internal OidEnumerator (OidCollection collection)
  20. {
  21. _collection = collection;
  22. _position = -1;
  23. }
  24. // properties
  25. public Oid Current {
  26. get {
  27. if (_position < 0)
  28. throw new ArgumentOutOfRangeException ();
  29. return (Oid) _collection [_position];
  30. }
  31. }
  32. object IEnumerator.Current {
  33. get {
  34. if (_position < 0)
  35. throw new ArgumentOutOfRangeException ();
  36. return _collection [_position];
  37. }
  38. }
  39. // methods
  40. public bool MoveNext ()
  41. {
  42. if (++_position < _collection.Count)
  43. return true;
  44. else {
  45. // strangely we must always be able to return the last entry
  46. _position = _collection.Count - 1;
  47. return false;
  48. }
  49. }
  50. public void Reset ()
  51. {
  52. _position = -1;
  53. }
  54. }
  55. }
  56. #endif