BerOutputStream.cs 948 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.IO;
  4. namespace Org.BouncyCastle.Asn1
  5. {
  6. // TODO Make Obsolete in favour of Asn1OutputStream?
  7. public class BerOutputStream
  8. : DerOutputStream
  9. {
  10. public BerOutputStream(Stream os) : base(os)
  11. {
  12. }
  13. [Obsolete("Use version taking an Asn1Encodable arg instead")]
  14. public override void WriteObject(
  15. object obj)
  16. {
  17. if (obj == null)
  18. {
  19. WriteNull();
  20. }
  21. else if (obj is Asn1Object)
  22. {
  23. ((Asn1Object)obj).Encode(this);
  24. }
  25. else if (obj is Asn1Encodable)
  26. {
  27. ((Asn1Encodable)obj).ToAsn1Object().Encode(this);
  28. }
  29. else
  30. {
  31. throw new IOException("object not BerEncodable");
  32. }
  33. }
  34. }
  35. }
  36. #endif