FromVector() public static method

public static FromVector ( Asn1EncodableVector v ) : DerSequence
v Asn1EncodableVector
return DerSequence
示例#1
0
        internal Asn1Object ReadTaggedObject(bool constructed, int tag)
        {
            if (!constructed)
            {
                DefiniteLengthInputStream definiteLengthInputStream = (DefiniteLengthInputStream)this._in;
                return(new DerTaggedObject(false, tag, new DerOctetString(definiteLengthInputStream.ToArray())));
            }
            Asn1EncodableVector asn1EncodableVector = this.ReadVector();

            if (this._in is IndefiniteLengthInputStream)
            {
                if (asn1EncodableVector.Count != 1)
                {
                    return(new BerTaggedObject(false, tag, BerSequence.FromVector(asn1EncodableVector)));
                }
                return(new BerTaggedObject(true, tag, asn1EncodableVector[0]));
            }
            else
            {
                if (asn1EncodableVector.Count != 1)
                {
                    return(new DerTaggedObject(false, tag, DerSequence.FromVector(asn1EncodableVector)));
                }
                return(new DerTaggedObject(true, tag, asn1EncodableVector[0]));
            }
        }
示例#2
0
        internal Asn1Object ReadTaggedObject(bool constructed, int tag)
        {
            if (!constructed)
            {
                // Note: !CONSTRUCTED => IMPLICIT
                DefiniteLengthInputStream defIn = (DefiniteLengthInputStream)_in;
                return(new DerTaggedObject(false, tag, new DerOctetString(defIn.ToArray())));
            }

            Asn1EncodableVector v = ReadVector();

            if (_in is IndefiniteLengthInputStream)
            {
                return(v.Count == 1
                                        ?   new BerTaggedObject(true, tag, v[0])
                                        :   new BerTaggedObject(false, tag, BerSequence.FromVector(v)));
            }

            return(v.Count == 1
                                ?   new DerTaggedObject(true, tag, v[0])
                                :   new DerTaggedObject(false, tag, DerSequence.FromVector(v)));
        }
示例#3
0
 internal virtual DerSequence CreateDerSequence(
     DefiniteLengthInputStream dIn)
 {
     return(DerSequence.FromVector(BuildDerEncodableVector(dIn)));
 }
示例#4
0
 internal virtual DerSequence CreateDerSequence(
     DefiniteLengthInputStream dIn)
 {
     return(DerSequence.FromVector(ReadVector(dIn)));
 }
示例#5
0
 internal virtual DerSequence CreateDerSequence(DefiniteLengthInputStream dIn) =>
 DerSequence.FromVector(this.BuildDerEncodableVector(dIn));
        public Asn1Object ToAsn1Object()
        {
            if (_indefiniteLength)
            {
                Asn1EncodableVector v = rLoadVector(_contentStream);

                return(v.Count == 1
                                        ?       new BerTaggedObject(true, _tagNumber, v[0])
                                        :       new BerTaggedObject(false, _tagNumber, BerSequence.FromVector(v)));
            }

            if (IsConstructed)
            {
                Asn1EncodableVector v = rLoadVector(_contentStream);

                return(v.Count == 1
                                        ?       new DerTaggedObject(true, _tagNumber, v[0])
                                        :       new DerTaggedObject(false, _tagNumber, DerSequence.FromVector(v)));
            }

            try
            {
                DefiniteLengthInputStream defIn = (DefiniteLengthInputStream)_contentStream;
                return(new DerTaggedObject(false, _tagNumber, new DerOctetString(defIn.ToArray())));
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(e.Message, e);
            }
        }