public TLVArray(AMQPType code, List <TLVAmqp> elements) : base(new SimpleConstructor(code)) { this.elements = elements; _width = code == AMQPType.ARRAY_8 ? 1 : 4; _size += _width; foreach (TLVAmqp element in elements) { _size += element.getLength() - element.Constructor.getLength(); if (elementConstructor == null && element != null) { elementConstructor = element.Constructor; } } _size += elementConstructor.getLength(); _count = elements.Count; }
public void addElement(TLVAmqp element) { if (elements.Count == 0) { elementConstructor = element.Constructor; _size += _width; _size += elementConstructor.getLength(); } elements.Add(element); _count++; _size += element.getLength() - elementConstructor.getLength(); if (_width == 1 && _size > 255) { Constructor.Code = AMQPType.ARRAY_32; _width = 4; _size += 3; } }