internal static void Decode(AsnReader reader, out Asn1PartialAttribute decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            Decode(reader, Asn1Tag.Sequence, out decoded);
        }
예제 #2
0
        internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out Asn1Change decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            decoded = new Asn1Change();
            AsnReader sequenceReader = reader.ReadSequence(expectedTag);

            decoded.Operation = sequenceReader.GetEnumeratedValue <ChangeOperation>();
            Asn1PartialAttribute.Decode(sequenceReader, out decoded.Modification);

            sequenceReader.ThrowIfNotEmpty();
        }
        internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out Asn1PartialAttribute decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            decoded = new Asn1PartialAttribute();
            AsnReader sequenceReader = reader.ReadSequence(expectedTag);
            AsnReader collectionReader;


            if (sequenceReader.TryGetPrimitiveOctetStringBytes(out ReadOnlyMemory <byte> tmpType))
            {
                decoded.Type = tmpType;
            }
            else
            {
                decoded.Type = sequenceReader.ReadOctetString();
            }


            // Decode SEQUENCE OF for Values
            {
                collectionReader = sequenceReader.ReadSetOf();
                var tmpList = new List <ReadOnlyMemory <byte> >();
                ReadOnlyMemory <byte> tmpItem;

                while (collectionReader.HasData)
                {
                    if (collectionReader.TryGetPrimitiveOctetStringBytes(out ReadOnlyMemory <byte> tmp))
                    {
                        tmpItem = tmp;
                    }
                    else
                    {
                        tmpItem = collectionReader.ReadOctetString();
                    }

                    tmpList.Add(tmpItem);
                }

                decoded.Values = tmpList.ToArray();
            }


            sequenceReader.ThrowIfNotEmpty();
        }
        internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out Asn1SearchResultEntry decoded)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            decoded = new Asn1SearchResultEntry();
            AsnReader sequenceReader = reader.ReadSequence(expectedTag);
            AsnReader collectionReader;


            if (sequenceReader.TryGetPrimitiveOctetStringBytes(out ReadOnlyMemory <byte> tmpObjectName))
            {
                decoded.ObjectName = tmpObjectName;
            }
            else
            {
                decoded.ObjectName = sequenceReader.ReadOctetString();
            }


            // Decode SEQUENCE OF for Attributes
            {
                collectionReader = sequenceReader.ReadSequence();
                var tmpList = new List <Asn1PartialAttribute>();
                Asn1PartialAttribute tmpItem;

                while (collectionReader.HasData)
                {
                    Asn1PartialAttribute.Decode(collectionReader, out tmpItem);
                    tmpList.Add(tmpItem);
                }

                decoded.Attributes = tmpList.ToArray();
            }


            sequenceReader.ThrowIfNotEmpty();
        }