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
|
|
@ -1,50 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using TeleSharp.TL;
|
||||
namespace TeleSharp.TL
|
||||
{
|
||||
public class ObjectUtils
|
||||
{
|
||||
public static object DeserializeObject(BinaryReader reader)
|
||||
{
|
||||
int Constructor = reader.ReadInt32();
|
||||
var Constructor = reader.ReadInt32();
|
||||
object obj;
|
||||
Type t =null;
|
||||
try {
|
||||
Type t = null;
|
||||
try
|
||||
{
|
||||
t = TLContext.getType(Constructor);
|
||||
obj = Activator.CreateInstance(t);
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
|
||||
}
|
||||
if (t.IsSubclassOf(typeof(TLMethod)))
|
||||
{
|
||||
((TLMethod)obj).deserializeResponse(reader);
|
||||
((TLMethod) obj).deserializeResponse(reader);
|
||||
return obj;
|
||||
}
|
||||
else if (t.IsSubclassOf(typeof(TLObject)))
|
||||
if (t.IsSubclassOf(typeof(TLObject)))
|
||||
{
|
||||
((TLObject)obj).DeserializeBody(reader);
|
||||
((TLObject) obj).DeserializeBody(reader);
|
||||
return obj;
|
||||
}
|
||||
else throw new NotImplementedException("Weird Type : " + t.Namespace + " | " + t.Name);
|
||||
throw new NotImplementedException("Weird Type : " + t.Namespace + " | " + t.Name);
|
||||
}
|
||||
public static void SerializeObject(object obj,BinaryWriter writer)
|
||||
|
||||
public static void SerializeObject(object obj, BinaryWriter writer)
|
||||
{
|
||||
((TLObject)obj).SerializeBody(writer);
|
||||
((TLObject) obj).SerializeBody(writer);
|
||||
}
|
||||
|
||||
public static TLVector<T> DeserializeVector<T>(BinaryReader reader)
|
||||
{
|
||||
if (reader.ReadInt32() != 481674261) throw new InvalidDataException("Bad Constructor");
|
||||
TLVector<T> t = new TLVector<T>();
|
||||
var t = new TLVector<T>();
|
||||
t.DeserializeBody(reader);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue