internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); try { writer.WriteObjectIdentifier(ExtnId); } catch (ArgumentException e) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e); } // DEFAULT value handler for Critical. { AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER); tmp.WriteBoolean(Critical); if (!tmp.EncodedValueEquals(DefaultCritical)) { tmp.CopyTo(writer); } } writer.WriteOctetString(ExtnValue.Span); writer.PopSequence(tag); }
internal void Encode(AsnWriter writer, Asn1Tag tag) { writer.PushSequence(tag); writer.WriteObjectIdentifier(ExtnId); // DEFAULT value handler for Critical. { using (AsnWriter tmp = new AsnWriter(AsnEncodingRules.DER)) { tmp.WriteBoolean(Critical); ReadOnlySpan <byte> encoded = tmp.EncodeAsSpan(); if (!encoded.SequenceEqual(s_defaultCritical)) { writer.WriteEncodedValue(encoded); } } } writer.WriteOctetString(ExtnValue.Span); writer.PopSequence(tag); }