Exemplo n.º 1
0
 public override void Read(TLBinaryReader from)
 {
     Id                     = from.ReadInt64();
     AccessHash             = from.ReadInt64();
     Date                   = from.ReadInt32();
     AdminId                = from.ReadInt32();
     ParticipantId          = from.ReadInt32();
     GAOrB                  = from.ReadByteArray();
     KeyFingerprint         = from.ReadInt64();
     Protocol               = TLFactory.Read <TLPhoneCallProtocol>(from);
     Connection             = TLFactory.Read <TLPhoneConnection>(from);
     AlternativeConnections = TLFactory.Read <TLVector <TLPhoneConnection> >(from);
     StartDate              = from.ReadInt32();
 }
Exemplo n.º 2
0
 public override void Read(TLBinaryReader from)
 {
     Flags       = (Flag)from.ReadInt32();
     Title       = from.ReadString();
     Description = from.ReadString();
     if (HasPhoto)
     {
         Photo = TLFactory.Read <TLInputWebDocument>(from);
     }
     Invoice      = TLFactory.Read <TLInvoice>(from);
     Payload      = from.ReadByteArray();
     Provider     = from.ReadString();
     ProviderData = TLFactory.Read <TLDataJSON>(from);
     StartParam   = from.ReadString();
 }
Exemplo n.º 3
0
 public override void Read(TLBinaryReader from)
 {
     Flags        = (Flag)from.ReadInt32();
     QueryId      = from.ReadInt64();
     UserId       = from.ReadInt32();
     MsgId        = TLFactory.Read <TLInputBotInlineMessageID>(from);
     ChatInstance = from.ReadInt64();
     if (HasData)
     {
         Data = from.ReadByteArray();
     }
     if (HasGameShortName)
     {
         GameShortName = from.ReadString();
     }
 }
 public override void Read(TLBinaryReader from)
 {
     Flags       = (Flag)from.ReadInt32();
     Currency    = from.ReadString();
     TotalAmount = from.ReadInt64();
     Payload     = from.ReadByteArray();
     if (HasInfo)
     {
         Info = TLFactory.Read <TLPaymentRequestedInfo>(from);
     }
     if (HasShippingOptionId)
     {
         ShippingOptionId = from.ReadString();
     }
     Charge = TLFactory.Read <TLPaymentCharge>(from);
 }
Exemplo n.º 5
0
 public override void Read(TLBinaryReader from)
 {
     Flags    = (Flag)from.ReadInt32();
     Duration = from.ReadInt32();
     if (HasTitle)
     {
         Title = from.ReadString();
     }
     if (HasPerformer)
     {
         Performer = from.ReadString();
     }
     if (HasWaveform)
     {
         Waveform = from.ReadByteArray();
     }
 }
Exemplo n.º 6
0
        //public override TLObject FromBytes(byte[] bytes, ref int position)
        //{
        //    bytes.ThrowExceptionIfIncorrect(ref position, 812830625u);
        //    PackedData = TLObject.GetObject<string>(bytes, ref position);
        //    byte[] array = new byte[0];
        //    byte[] data = PackedData.Data;
        //    byte[] array2 = new byte[4096];
        //    GZipStream gZipStream = new GZipStream(new MemoryStream(data), CompressionMode.Decompress);
        //    int i;
        //    for (i = gZipStream.Read(array2, 0, array2.Length); i > 0; i = gZipStream.Read(array2, 0, array2.Length))
        //    {
        //        array = TLUtils.Combine(new byte[][]
        //        {
        //            array,
        //            array2.SubArray(0, i)
        //        });
        //    }
        //    i = 0;
        //    Data = TLObject.GetObject<TLObject>(array, ref i);
        //    return this;
        //}

        public override void Read(TLBinaryReader from)
        {
            var data   = from.ReadByteArray();
            var buffer = new byte[4096];

            using (var input = new MemoryStream())
            {
                using (var stream = new GZipStream(new MemoryStream(data), CompressionMode.Decompress))
                {
                    for (int i = stream.Read(buffer, 0, buffer.Length); i > 0; i = stream.Read(buffer, 0, buffer.Length))
                    {
                        input.Write(buffer, 0, buffer.Length);
                    }
                }

                input.Seek(0, SeekOrigin.Begin);
                using (var reader = new TLBinaryReader(input))
                {
                    Query = TLFactory.Read <TLObject>(reader);
                }
            }
        }
Exemplo n.º 7
0
 public override void Read(TLBinaryReader from)
 {
     Bytes = from.ReadByteArray();
 }
Exemplo n.º 8
0
 public override void Read(TLBinaryReader from)
 {
     RequestToken = from.ReadByteArray();
 }
Exemplo n.º 9
0
        public static T Read <T>(TLBinaryReader from)
        {
            if (typeof(T) == typeof(UInt32))
            {
                return((T)(Object)from.ReadUInt32());
            }
            else if (typeof(T) == typeof(Int32))
            {
                return((T)(Object)from.ReadInt32());
            }
            else if (typeof(T) == typeof(UInt64))
            {
                return((T)(Object)from.ReadUInt64());
            }
            else if (typeof(T) == typeof(Int64))
            {
                return((T)(Object)from.ReadInt64());
            }
            else if (typeof(T) == typeof(Double))
            {
                return((T)(Object)from.ReadDouble());
            }
            else if (typeof(T) == typeof(Boolean))
            {
                return((T)(Object)from.ReadBoolean());
            }
            else if (typeof(T) == typeof(String))
            {
                return((T)(Object)from.ReadString());
            }
            else if (typeof(T) == typeof(Byte[]))
            {
                return((T)(Object)from.ReadByteArray());
            }
            else if (typeof(T) == typeof(TLInt128))
            {
                return((T)(Object) new TLInt128(from));
            }
            else if (typeof(T) == typeof(TLInt256))
            {
                return((T)(Object) new TLInt256(from));
            }
            else if (typeof(T) == typeof(TLNonEncryptedTransportMessage))
            {
                return((T)(Object) new TLNonEncryptedTransportMessage(from));
            }

            var type = from.ReadUInt32();

            if (type == 0xFFFFFF0D || typeof(T) == typeof(TLActionInfo))
            {
                return((T)(Object) new TLActionInfo(from));
            }
            else if ((TLType)type == TLType.Vector)
            {
                if (typeof(T) != typeof(object) && typeof(T) != typeof(TLObject))
                {
                    return((T)(Object)Activator.CreateInstance(typeof(T), from));
                }
                else
                {
                    var length = from.ReadUInt32();
                    if (length > 0)
                    {
                        var inner = from.ReadUInt32();
                        from.BaseStream.Position -= 8;

                        var innerType = Type.GetType($"Telegram.Api.TL.TL{(TLType)inner}");
                        if (innerType != null)
                        {
                            var baseType = innerType.GetTypeInfo().BaseType;
                            if (baseType.Name != "TLObject")
                            {
                                innerType = baseType;
                            }

                            var d1       = typeof(TLVector <>);
                            var typeArgs = new Type[] { innerType };
                            var makeme   = d1.MakeGenericType(typeArgs);
                            return((T)(Object)Activator.CreateInstance(makeme, from));
                        }
                        else
                        {
                            // A base type collection (int, long, double, bool)
                            // TODO:
                            return((T)(Object)null);
                        }
                    }
                    else
                    {
                        // An empty collection, so we can't determine the generic type
                        // TODO:
                        return((T)(Object) new TLVectorEmpty());
                    }
                }
            }
            else if (type == 0x997275b5 || type == 0x3fedd339)
            {
                return((T)(Object)true);
            }
            else if (type == 0xbc799737)
            {
                return((T)(Object)false);
            }
            else
            {
                return(Read <T>(from, (TLType)type));
            }
        }
Exemplo n.º 10
0
 public override void Read(TLBinaryReader from)
 {
     TmpPassword = from.ReadByteArray();
     ValidUntil  = from.ReadInt32();
 }
Exemplo n.º 11
0
 public override void Read(TLBinaryReader from)
 {
     Text = from.ReadString();
     Data = from.ReadByteArray();
 }
Exemplo n.º 12
0
 public override void Read(TLBinaryReader from)
 {
     Offset = from.ReadInt32();
     Limit  = from.ReadInt32();
     Hash   = from.ReadByteArray();
 }
 public override void Read(TLBinaryReader from)
 {
     Id    = from.ReadInt32();
     Bytes = from.ReadByteArray();
 }
Exemplo n.º 14
0
 public override void Read(TLBinaryReader from)
 {
     Nonce           = new TLInt128(from);
     ServerNonce     = new TLInt128(from);
     EncryptedAnswer = from.ReadByteArray();
 }
Exemplo n.º 15
0
 public override void Read(TLBinaryReader from)
 {
     NewSalt = from.ReadByteArray();
     EmailUnconfirmedPattern = from.ReadString();
 }
Exemplo n.º 16
0
 public override void Read(TLBinaryReader from)
 {
     Id          = from.ReadString();
     TmpPassword = from.ReadByteArray();
 }
Exemplo n.º 17
0
 public override void Read(TLBinaryReader from)
 {
     Type  = TLFactory.Read <TLStorageFileTypeBase>(from);
     Mtime = from.ReadInt32();
     Bytes = from.ReadByteArray();
 }