Asn1EncodableVector.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.Collections;
  4. using Org.BouncyCastle.Utilities;
  5. namespace Org.BouncyCastle.Asn1
  6. {
  7. public class Asn1EncodableVector
  8. : IEnumerable
  9. {
  10. private IList v = Org.BouncyCastle.Utilities.Platform.CreateArrayList();
  11. public static Asn1EncodableVector FromEnumerable(
  12. IEnumerable e)
  13. {
  14. Asn1EncodableVector v = new Asn1EncodableVector();
  15. foreach (Asn1Encodable obj in e)
  16. {
  17. v.Add(obj);
  18. }
  19. return v;
  20. }
  21. // public Asn1EncodableVector()
  22. // {
  23. // }
  24. public Asn1EncodableVector(
  25. params Asn1Encodable[] v)
  26. {
  27. Add(v);
  28. }
  29. // public void Add(
  30. // Asn1Encodable obj)
  31. // {
  32. // v.Add(obj);
  33. // }
  34. public void Add(
  35. params Asn1Encodable[] objs)
  36. {
  37. foreach (Asn1Encodable obj in objs)
  38. {
  39. v.Add(obj);
  40. }
  41. }
  42. public void AddOptional(
  43. params Asn1Encodable[] objs)
  44. {
  45. if (objs != null)
  46. {
  47. foreach (Asn1Encodable obj in objs)
  48. {
  49. if (obj != null)
  50. {
  51. v.Add(obj);
  52. }
  53. }
  54. }
  55. }
  56. public Asn1Encodable this[
  57. int index]
  58. {
  59. get { return (Asn1Encodable) v[index]; }
  60. }
  61. [Obsolete("Use 'object[index]' syntax instead")]
  62. public Asn1Encodable Get(
  63. int index)
  64. {
  65. return this[index];
  66. }
  67. [Obsolete("Use 'Count' property instead")]
  68. public int Size
  69. {
  70. get { return v.Count; }
  71. }
  72. public int Count
  73. {
  74. get { return v.Count; }
  75. }
  76. public IEnumerator GetEnumerator()
  77. {
  78. return v.GetEnumerator();
  79. }
  80. }
  81. }
  82. #endif