fixed some DtsodV23 bugs, but there still more

This commit is contained in:
timerix 2022-09-26 01:46:27 +06:00
parent 55ef06e484
commit 9f07cc78e3

View File

@ -280,7 +280,7 @@ public class DtsodV23 : DtsodDict<string, dynamic>, IDtsod
internal static readonly Dictionary<Type, Action<dynamic, StringBuilder>> TypeSerializeFuncs = new()
{
{ typeof(bool), (val, b) => b.Append(val.ToString()) },
{ typeof(bool), (val, b) => b.Append((bool)val ? "true" : "false") },
{ typeof(char), (val, b) => b.Append('\'').Append(val).Append('\'') },
{ typeof(string), (val, b) => b.Append('"').Append(val.Replace("\\","\\\\").Replace("\"", "\\\"")).Append('"') },
{ typeof(byte), (val, b) => b.Append(val.ToString()).Append('b') },
@ -318,12 +318,15 @@ public class DtsodV23 : DtsodDict<string, dynamic>, IDtsod
else if (value is IList _list)
{
b.Append('[');
if(_list.Count>0){
foreach (object el in _list)
{
SerializeType(el, ref tabscount);
b.Append(',');
}
b.Remove(b.Length - 1, 1).Append(']');
b.Remove(b.Length - 1, 1);
}
b.Append(']');
}
else TypeSerializeFuncs[value.GetType()].Invoke(value, b);
}