public void Write(BerTag tag, long value) { var valueLength = BerEncoding.GetLongLength(value); WriteOuterHeader(tag, valueLength + 2); BerEncoding.EncodeTag(_output, new BerTag(BerType.Integer)); BerEncoding.EncodeLength(_output, valueLength); BerEncoding.EncodeLong(_output, value, (int)valueLength); }
/// <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.GetLongLength(Value); BerEncoding.EncodeTag(output, Tag.ToContainer()); BerEncoding.EncodeLength(output, valueLength + 2); BerEncoding.EncodeTag(output, new BerTag(BerType.Integer)); BerEncoding.EncodeLength(output, valueLength); BerEncoding.EncodeLong(output, Value, valueLength); Encoded = output.ToArray(); EncodedLength = Encoded.Length; return(EncodedLength); }