Esempio n. 1
0
        public void Write(BerTag tag, int value)
        {
            var valueLength = BerEncoding.GetIntegerLength(value);

            WriteOuterHeader(tag, valueLength + 2);
            BerEncoding.EncodeTag(_output, new BerTag(BerType.Integer));
            BerEncoding.EncodeLength(_output, valueLength);
            BerEncoding.EncodeInteger(_output, value, (int)valueLength);
        }
Esempio n. 2
0
        /// <summary>
        /// Pre-encodes the BER header and returns the byte length of the encoded node.
        /// Overriden to encode the entire TLTLV
        /// </summary>
        /// <returns>The length of the encoded node.</returns>
        internal override int Update()
        {
            var output      = new BerMemoryOutput();
            var valueLength = BerEncoding.GetIntegerLength(Value);

            BerEncoding.EncodeTag(output, Tag.ToContainer());
            BerEncoding.EncodeLength(output, valueLength + 2);

            BerEncoding.EncodeTag(output, new BerTag(BerType.Integer));
            BerEncoding.EncodeLength(output, valueLength);
            BerEncoding.EncodeInteger(output, Value, valueLength);

            Encoded       = output.ToArray();
            EncodedLength = Encoded.Length;
            return(EncodedLength);
        }