public void Encode(BinaryWriter writer) { EsfType containedTypeCode = ContainedTypeCode; EsfType myRealType = (EsfType)(containedTypeCode + 0x40); #if DEBUG Console.WriteLine("encoding array with {2} bytes, code {0} containing {1}", myRealType, containedTypeCode, Value.Length); #endif writer.Write((byte)myRealType); byte[] encodedArray = new byte[0]; using (var stream = new MemoryStream()) { using (var memWriter = new BinaryWriter(stream)) { CodecNode <T> valueNode = Codec.CreateValueNode(containedTypeCode, false) as CodecNode <T>; valueNode.TypeCode = containedTypeCode; foreach (T item in Value) { valueNode.Value = item; valueNode.WriteValue(memWriter); } encodedArray = stream.ToArray(); #if DEBUG Console.WriteLine("size is {0}", encodedArray.Length); #endif Codec.WriteOffset(writer, encodedArray.Length); writer.Write(encodedArray); } } }