mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-07 07:25:24 +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,21 +1,16 @@
|
|||
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 TLObjectAttribute : Attribute
|
||||
{
|
||||
public int Constructor { get; private set; }
|
||||
|
||||
public TLObjectAttribute(int Constructor)
|
||||
{
|
||||
this.Constructor = Constructor;
|
||||
}
|
||||
|
||||
public int Constructor { get; }
|
||||
}
|
||||
|
||||
public abstract class TLObject
|
||||
|
|
@ -23,10 +18,11 @@ namespace TeleSharp.TL
|
|||
public abstract int Constructor { get; }
|
||||
public abstract void SerializeBody(BinaryWriter bw);
|
||||
public abstract void DeserializeBody(BinaryReader br);
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
using (MemoryStream m = new MemoryStream())
|
||||
using (BinaryWriter bw = new BinaryWriter(m))
|
||||
using (var m = new MemoryStream())
|
||||
using (var bw = new BinaryWriter(m))
|
||||
{
|
||||
Serialize(bw);
|
||||
bw.Close();
|
||||
|
|
@ -34,17 +30,19 @@ namespace TeleSharp.TL
|
|||
return m.GetBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Constructor);
|
||||
SerializeBody(writer);
|
||||
}
|
||||
|
||||
public void Deserialize(BinaryReader reader)
|
||||
{
|
||||
int constructorId = reader.ReadInt32();
|
||||
var constructorId = reader.ReadInt32();
|
||||
if (constructorId != Constructor)
|
||||
throw new InvalidDataException("Constructor Invalid");
|
||||
DeserializeBody(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue