This commit is contained in:
Ilya P 2016-10-29 09:53:45 +03:00
parent 263685f050
commit df66bfb6e3

View file

@ -22,7 +22,7 @@ namespace TeleSharp.TL
public override void DeserializeBody(BinaryReader br) public override void DeserializeBody(BinaryReader br)
{ {
int count = br.ReadInt32(); int count = br.ReadInt32();
for(int i= 0;i< count;i++) for (var i = 0; i < count; i++)
{ {
if (typeof(T) == typeof(int)) if (typeof(T) == typeof(int))
{ {
@ -56,9 +56,34 @@ namespace TeleSharp.TL
bw.Write(Constructor); bw.Write(Constructor);
bw.Write(lists.Count()); bw.Write(lists.Count());
foreach (var item in lists.Cast<TLObject>()) foreach (var item in lists)
{ {
item.SerializeBody(bw); if (typeof(T) == typeof(int))
{
var res = (int)Convert.ChangeType(item, typeof(int));
bw.Write(res);
}
else if (typeof(T) == typeof(long))
{
var res = (long)Convert.ChangeType(item, typeof(long));
bw.Write(res);
}
else if (typeof(T) == typeof(string))
{
var res = (string)(Convert.ChangeType(item, typeof(string)));
StringUtil.Serialize(res, bw);
}
else if (typeof(T) == typeof(double))
{
var res = (double)Convert.ChangeType(item, typeof(double));
bw.Write(res);
}
else if (typeof(T).BaseType == typeof(TLObject))
{
var res = (TLObject) (Convert.ChangeType(item, typeof (TLObject)));
res.SerializeBody(bw);
}
} }
} }
} }