Exemple #1
0
    void WriteCustom(TableWriter writer, ValueList list, bool array)
    {
        var type = CustomType;

        if (array)
        {
            if (list.IsEmptyValue())
            {
                writer.WriteInt32(0);
            }
            else
            {
                writer.WriteInt32(list.Count);
                for (var i = 0; i < list.Count; ++i)
                {
                    WriteCustom(writer, list[i] as ValueList, false);
                }
            }
        }
        else
        {
            if (list.IsEmptyValue())
            {
                for (var i = 0; i < type.Fields.Count; ++i)
                {
                    type.Fields[i].Write(writer, new ValueString(""));
                }
            }
            else
            {
                var count = list.Count;
                if (count != type.Fields.Count)
                {
                    throw new Exception($"字段数量与{type.Name}需求数量不一致 需要:{type.Fields.Count} 填写数量:{count} ");
                }
                for (var i = 0; i < count; ++i)
                {
                    type.Fields[i].Write(writer, list[i]);
                }
            }
        }
    }