mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-07 15:36:23 +00:00
apply resharper's code style
This commit is contained in:
parent
1697db9d7f
commit
7fad829dd2
776 changed files with 14393 additions and 24502 deletions
|
|
@ -2,53 +2,43 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeleSharp.TL
|
||||
{
|
||||
public class TLVector<T> : TLObject
|
||||
{
|
||||
[TLObject(481674261)]
|
||||
public List<T> lists = new List<T>();
|
||||
public override int Constructor
|
||||
{
|
||||
get
|
||||
{
|
||||
return 481674261;
|
||||
}
|
||||
}
|
||||
[TLObject(481674261)] public List<T> lists = new List<T>();
|
||||
|
||||
public override int Constructor => 481674261;
|
||||
|
||||
public override void DeserializeBody(BinaryReader br)
|
||||
{
|
||||
int count = br.ReadInt32();
|
||||
var count = br.ReadInt32();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
lists.Add((T)Convert.ChangeType(br.ReadInt32(), typeof(T)));
|
||||
lists.Add((T) Convert.ChangeType(br.ReadInt32(), typeof(T)));
|
||||
}
|
||||
else if (typeof(T) == typeof(long))
|
||||
{
|
||||
lists.Add((T)Convert.ChangeType(br.ReadInt64(), typeof(T)));
|
||||
lists.Add((T) Convert.ChangeType(br.ReadInt64(), typeof(T)));
|
||||
}
|
||||
else if (typeof(T) == typeof(string))
|
||||
{
|
||||
lists.Add((T)Convert.ChangeType(StringUtil.Deserialize(br), typeof(T)));
|
||||
lists.Add((T) Convert.ChangeType(StringUtil.Deserialize(br), typeof(T)));
|
||||
}
|
||||
else if (typeof(T) == typeof(double))
|
||||
{
|
||||
lists.Add((T)Convert.ChangeType(br.ReadDouble(), typeof(T)));
|
||||
lists.Add((T) Convert.ChangeType(br.ReadDouble(), typeof(T)));
|
||||
}
|
||||
else if (typeof(T).BaseType == typeof(TLObject))
|
||||
{
|
||||
int constructor = br.ReadInt32();
|
||||
Type type = TLContext.getType(constructor);
|
||||
object obj = Activator.CreateInstance(type);
|
||||
type.GetMethod("DeserializeBody").Invoke(obj, new object[] { br });
|
||||
lists.Add((T)Convert.ChangeType(obj, type));
|
||||
var constructor = br.ReadInt32();
|
||||
var type = TLContext.getType(constructor);
|
||||
var obj = Activator.CreateInstance(type);
|
||||
type.GetMethod("DeserializeBody").Invoke(obj, new object[] {br});
|
||||
lists.Add((T) Convert.ChangeType(obj, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void SerializeBody(BinaryWriter bw)
|
||||
|
|
@ -57,34 +47,32 @@ namespace TeleSharp.TL
|
|||
bw.Write(lists.Count());
|
||||
|
||||
foreach (var item in lists)
|
||||
{
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
var res = (int)Convert.ChangeType(item, 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));
|
||||
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)));
|
||||
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));
|
||||
var res = (double) Convert.ChangeType(item, typeof(double));
|
||||
bw.Write(res);
|
||||
}
|
||||
else if (typeof(T).BaseType == typeof(TLObject))
|
||||
{
|
||||
var res = (TLObject)(object)item;
|
||||
var res = (TLObject) (object) item;
|
||||
res.SerializeBody(bw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue