Asn1OutputStream.cs 897 B

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