public override async Task <int> Write(IAsn1Serializer asn1Serializer, Asn1Enumerated item, Stream stream, CancellationToken cancellationToken)
        {
            var identBytes = await SerializerUtility.WriteIdentifier(item.Id, stream, cancellationToken);

            var bytes = await SerializerUtility.WriteIntegerValue(item.Value, stream, cancellationToken);

            return(identBytes + bytes);
        }
Ejemplo n.º 2
0
        public override async Task <int> Write(IAsn1Serializer asn1Serializer, Asn1OctetString item, Stream stream, CancellationToken cancellationToken)
        {
            var identBytes = await SerializerUtility.WriteIdentifier(item.Id, stream, cancellationToken);

            var lenBytes = await SerializerUtility.WriteLength(item.Data.Length, stream, cancellationToken);

            await stream.WriteBERBytes(item.Data, cancellationToken : cancellationToken);

            return(identBytes + lenBytes + item.Data.Length);
        }
        public override async Task <int> Write(IAsn1Serializer serializer, Asn1Boolean item, Stream stream,
                                               CancellationToken cancellationToken)
        {
            var boolean    = (Asn1Boolean)item;
            var identBytes = await SerializerUtility.WriteIdentifier(item.Id, stream, cancellationToken);

            var buffer = new byte[] { 1, boolean.Value?(byte)0xff :(byte)0x00 };
            await stream.WriteBERBytes(buffer, cancellationToken : cancellationToken);

            return(identBytes + buffer.Length);
        }
        public override async Task <int> Write(IAsn1Serializer asn1Serializer, Asn1Set item, Stream stream, CancellationToken cancellationToken)
        {
            var(ms, setItemBytes) =
                await SerializerUtility.WriteItemsToBufferedStream(asn1Serializer, item.Items, cancellationToken);

            var identBytes = await SerializerUtility.WriteIdentifier(item.Id, stream, cancellationToken);

            var lenBytes = await SerializerUtility.WriteLength(setItemBytes, stream, cancellationToken);

            await ms.CopyToAsync(stream, cancellationToken);

            return(identBytes + lenBytes + setItemBytes);
        }
Ejemplo n.º 5
0
 public override async Task <int> Write(IAsn1Serializer asn1Serializer, Asn1Null item, Stream stream, CancellationToken cancellationToken)
 {
     return(await SerializerUtility.WriteIdentifier(item.Id, stream, cancellationToken));
 }