TLSharp/TeleSharp.TL/TL/Auth/TLSentCode.cs

73 lines
2 KiB
C#
Raw Normal View History

2016-09-24 15:38:26 +02:00
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.Auth
{
[TLObject(1577067778)]
2016-09-24 15:38:26 +02:00
public class TLSentCode : TLObject
{
public override int Constructor
{
get
{
return 1577067778;
}
}
public int flags { get; set; }
public bool phone_registered { get; set; }
public Auth.TLAbsSentCodeType type { get; set; }
public string phone_code_hash { get; set; }
public Auth.TLAbsCodeType next_type { get; set; }
public int? timeout { get; set; }
2016-09-24 15:38:26 +02:00
public void ComputeFlags()
{
flags = 0;
flags = phone_registered ? (flags | 1) : (flags & ~1);
flags = next_type != null ? (flags | 2) : (flags & ~2);
flags = timeout != null ? (flags | 4) : (flags & ~4);
2016-09-24 15:38:26 +02:00
}
2016-09-24 15:38:26 +02:00
public override void DeserializeBody(BinaryReader br)
{
flags = br.ReadInt32();
phone_registered = (flags & 1) != 0;
type = (Auth.TLAbsSentCodeType)ObjectUtils.DeserializeObject(br);
phone_code_hash = StringUtil.Deserialize(br);
if ((flags & 2) != 0)
next_type = (Auth.TLAbsCodeType)ObjectUtils.DeserializeObject(br);
else
next_type = null;
2016-09-24 15:38:26 +02:00
if ((flags & 4) != 0)
timeout = br.ReadInt32();
else
timeout = null;
2016-09-24 15:38:26 +02:00
}
public override void SerializeBody(BinaryWriter bw)
{
bw.Write(Constructor);
2016-09-24 15:38:26 +02:00
ComputeFlags();
bw.Write(flags);
2016-09-24 15:38:26 +02:00
ObjectUtils.SerializeObject(type, bw);
StringUtil.Serialize(phone_code_hash, bw);
if ((flags & 2) != 0)
ObjectUtils.SerializeObject(next_type, bw);
if ((flags & 4) != 0)
bw.Write(timeout.Value);
2016-09-24 15:38:26 +02:00
}
}
}