Ejemplo n.º 1
0
        /// <summary>
        ///     This method returns a byte array representing the encoded
        ///     Asn1Object.  It in turn calls the encode method that is
        ///     defined in Asn1Object but will usually be implemented
        ///     in the child Asn1 classses.
        /// </summary>
        public byte[] GetEncoding(IAsn1Encoder enc)
        {
            var outRenamed = new MemoryStream();

            try
            {
                Encode(enc, outRenamed);
            }
            catch (IOException e)
            {
                // Should never happen - the current Asn1Object does not have
                // a encode method.
                throw new Exception("IOException while encoding to byte array: " + e);
            }

            return(outRenamed.ToArray());
        }
        /* Asn1Object implementation
         */

        /// <summary>
        ///     Call this method to encode the current instance into the
        ///     specified output stream using the specified encoder object.
        /// </summary>
        /// <param name="enc">
        ///     Encoder object to use when encoding self.
        /// </param>
        /// <param name="out">
        ///     The output stream onto which the encoded byte
        ///     stream is written.
        /// </param>
        public override void Encode(IAsn1Encoder enc, Stream outRenamed)
        {
            enc.Encode(this, outRenamed);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Abstract method that must be implemented by each child
 ///     class to encode itself ( an Asn1Object) directly intto
 ///     a output stream.
 /// </summary>
 /// <param name="out">
 ///     The output stream onto which the encoded
 ///     Asn1Object will be placed.
 /// </param>
 public abstract void Encode(IAsn1Encoder enc, Stream outRenamed);
Ejemplo n.º 4
0
        /* Asn1Object implementation
         */

        /// <summary>
        ///     Call this method to encode the contents of this Asn1Choice
        ///     instance into the specified output stream using the
        ///     specified encoder object.
        /// </summary>
        /// <param name="enc">
        ///     Encoder object to use when encoding self.
        /// </param>
        /// <param name="out">
        ///     The output stream onto which the encoded byte
        ///     stream is written.
        /// </param>
        public override void Encode(IAsn1Encoder enc, Stream outRenamed)
        {
            ChoiceValue.Encode(enc, outRenamed);
        }