TLSharp/TeleSharp.TL/TL/TLMessageMediaDocument.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2016-09-24 15:38:26 +02:00
using System.IO;
namespace TeleSharp.TL
{
2017-11-09 10:21:33 +01:00
[TLObject(2084836563)]
2016-09-24 15:38:26 +02:00
public class TLMessageMediaDocument : TLAbsMessageMedia
{
public override int Constructor
{
get
{
2017-11-09 10:21:33 +01:00
return 2084836563;
2016-09-24 15:38:26 +02:00
}
}
2017-11-09 10:21:33 +01:00
public int flags { get; set; }
public TLAbsDocument document { get; set; }
public string caption { get; set; }
2017-11-09 10:21:33 +01:00
public int? ttl_seconds { get; set; }
2016-09-24 15:38:26 +02:00
public void ComputeFlags()
{
2017-11-09 10:21:33 +01:00
flags = 0;
flags = document != null ? (flags | 1) : (flags & ~1);
flags = caption != null ? (flags | 2) : (flags & ~2);
flags = ttl_seconds != null ? (flags | 4) : (flags & ~4);
}
2016-09-24 15:38:26 +02:00
public override void DeserializeBody(BinaryReader br)
{
2017-11-09 10:21:33 +01:00
flags = br.ReadInt32();
if ((flags & 1) != 0)
document = (TLAbsDocument)ObjectUtils.DeserializeObject(br);
else
document = null;
if ((flags & 2) != 0)
caption = StringUtil.Deserialize(br);
else
caption = null;
if ((flags & 4) != 0)
ttl_seconds = br.ReadInt32();
else
ttl_seconds = null;
2016-09-24 15:38:26 +02:00
}
public override void SerializeBody(BinaryWriter bw)
{
bw.Write(Constructor);
2017-11-09 10:21:33 +01:00
ComputeFlags();
bw.Write(flags);
if ((flags & 1) != 0)
ObjectUtils.SerializeObject(document, bw);
if ((flags & 2) != 0)
StringUtil.Serialize(caption, bw);
if ((flags & 4) != 0)
bw.Write(ttl_seconds.Value);
2016-09-24 15:38:26 +02:00
}
}
}