Пример #1
0
        public override void Update(TLPhotoBase photo)
        {
            var mediaPhoto = photo as TLMediaPhotoBase;

            if (mediaPhoto != null)
            {
                Id = mediaPhoto.Id;
            }
        }
Пример #2
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            ChatId     = GetObject <TLInt>(bytes, ref position);
            AccessHash = GetObject <TLLong>(bytes, ref position);

            return(this);
        }
Пример #3
0
        public static T GetObject <T>(TLLong customFlags, int flag, T defaultValue, Stream inputStream) where T : TLObject
        {
            var value = IsSet(customFlags, flag) ? GetObject <T>(inputStream) : defaultValue;

            //if (value != null)
            //{
            //    Set(ref customFlags, flag);
            //}
            return(value);
        }
Пример #4
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Text      = GetObject <TLRichTextBase>(bytes, ref position);
            Url       = GetObject <TLString>(bytes, ref position);
            WebPageId = GetObject <TLLong>(bytes, ref position);

            return(this);
        }
Пример #5
0
        public override TLObject FromStream(Stream input)
        {
            Id      = GetObject <TLLong>(input);
            Ip      = GetObject <TLString>(input);
            IpV6    = GetObject <TLString>(input);
            Port    = GetObject <TLInt>(input);
            PeerTag = GetObject <TLString>(input);

            return(this);
        }
Пример #6
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            PhotoId    = GetObject <TLLong>(bytes, ref position);
            PhotoSmall = GetObject <TLFileLocationBase>(bytes, ref position);
            PhotoBig   = GetObject <TLFileLocationBase>(bytes, ref position);

            return(this);
        }
Пример #7
0
        public static string MessageIdString(TLLong messageId)
        {
            var bytes = BitConverter.GetBytes(messageId.Value);
            var ticks = BitConverter.ToInt64(bytes, 0);
            var date  = Utils.UnixTimestampToDateTime(ticks >> 32);

            return(BitConverter.ToString(bytes) + " "
                   + ticks + "%4=" + ticks % 4 + " "
                   + date);
        }
Пример #8
0
        public override TLObject FromStream(Stream input)
        {
            Url        = GetObject <TLString>(input);
            AccessHash = GetObject <TLLong>(input);
            Size       = GetObject <TLInt>(input);
            MimeType   = GetObject <TLString>(input);
            Attributes = GetObject <TLVector <TLDocumentAttributeBase> >(input);

            return(this);
        }
Пример #9
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            QueryId = GetObject <TLLong>(bytes, ref position);
            Code    = GetObject <TLInt>(bytes, ref position);
            Message = GetObject <TLString>(bytes, ref position);

            return(this);
        }
Пример #10
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            ExchangeId     = GetObject <TLLong>(bytes, ref position);
            GB             = GetObject <TLString>(bytes, ref position);
            KeyFingerprint = GetObject <TLLong>(bytes, ref position);

            return(this);
        }
Пример #11
0
        public override TLObject FromStream(Stream input)
        {
            DCId                  = GetObject <TLInt>(input);
            PublicKey             = GetObject <TLString>(input);
            CustomFlags           = GetObject <TLLong>(input);
            _publicKeyFingerprint = GetObject <TLLong>(CustomFlags, (int)CdnPublicKeyCustomFlags.PublicKeyFingerprint, null, input);


            return(this);
        }
Пример #12
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            TLUtils.WriteLine("--Parse TLInputPeerForeign--");
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            UserId     = GetObject <TLInt>(bytes, ref position);
            AccessHash = GetObject <TLLong>(bytes, ref position);

            return(this);
        }
Пример #13
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Email          = GetObject <TLString>(bytes, ref position);
            SecureSalt     = GetObject <TLString>(bytes, ref position);
            SecureSecret   = GetObject <TLString>(bytes, ref position);
            SecureSecretId = GetObject <TLLong>(bytes, ref position);

            return(this);
        }
Пример #14
0
 protected static void SetUnset(ref TLLong flags, bool set, int flag)
 {
     if (set)
     {
         Set(ref flags, flag);
     }
     else
     {
         Unset(ref flags, flag);
     }
 }
Пример #15
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            DCId      = GetObject <TLInt>(bytes, ref position);
            PublicKey = GetObject <TLString>(bytes, ref position);

            CustomFlags = new TLLong(0);

            return(this);
        }
Пример #16
0
        public static void ToStream(Stream output, TLObject obj, TLLong customFlags, int flag)
        {
            if (IsSet(customFlags, flag))
            {
                if (obj == null)
                {
                }

                obj.ToStream(output);
            }
        }
Пример #17
0
        protected static bool IsSet(TLLong flags, int flag)
        {
            var isSet = false;

            if (flags != null)
            {
                var intFlag = flag;
                isSet = (flags.Value & intFlag) == intFlag;
            }

            return(isSet);
        }
Пример #18
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Url        = GetObject <TLString>(bytes, ref position);
            AccessHash = GetObject <TLLong>(bytes, ref position);
            Size       = GetObject <TLInt>(bytes, ref position);
            MimeType   = GetObject <TLString>(bytes, ref position);
            Attributes = GetObject <TLVector <TLDocumentAttributeBase> >(bytes, ref position);

            return(this);
        }
Пример #19
0
        public override TLObject FromStream(Stream input)
        {
            Flags          = GetObject <TLInt>(input);
            _url           = GetObject <TLString>(Flags, (int)PageBlockEmbedFlags.Url, null, input);
            _html          = GetObject <TLString>(Flags, (int)PageBlockEmbedFlags.Html, null, input);
            _posterPhotoId = GetObject <TLLong>(Flags, (int)PageBlockEmbedFlags.PosterPhotoId, null, input);
            W       = GetObject <TLInt>(input);
            H       = GetObject <TLInt>(input);
            Caption = GetObject <TLRichTextBase>(input);

            return(this);
        }
Пример #20
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Expires     = GetObject <TLInt>(bytes, ref position);
            Peer        = GetObject <TLPeerBase>(bytes, ref position);
            Chats       = GetObject <TLVector <TLChatBase> >(bytes, ref position);
            Users       = GetObject <TLVector <TLUserBase> >(bytes, ref position);
            CustomFlags = new TLLong(0);

            return(this);
        }
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            Salt      = GetObject <TLLong>(bytes, ref position);
            SessionId = GetObject <TLLong>(bytes, ref position);

            MessageId         = GetObject <TLLong>(bytes, ref position);
            SeqNo             = GetObject <TLInt>(bytes, ref position);
            MessageDataLength = GetObject <TLInt>(bytes, ref position);
            MessageData       = GetObject <TLObject>(bytes, ref position);

            return(this);
        }
Пример #22
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Id      = GetObject <TLLong>(bytes, ref position);
            Ip      = GetObject <TLString>(bytes, ref position);
            IpV6    = GetObject <TLString>(bytes, ref position);
            Port    = GetObject <TLInt>(bytes, ref position);
            PeerTag = GetObject <TLString>(bytes, ref position);

            return(this);
        }
Пример #23
0
        protected static void Set(ref TLLong flags, int flag)
        {
            var intFlag = flag;

            if (flags != null)
            {
                flags.Value |= intFlag;
            }
            else
            {
                flags = new TLLong(intFlag);
            }
        }
Пример #24
0
        public override TLObject FromStream(Stream input)
        {
            Id    = GetObject <TLInt>(input);
            Title = GetObject <TLString>(input);
            //Date = GetObject<TLInt>(input);

            Participants   = GetObject <TLObject>(input) as TLChatParticipantsBase;
            NotifySettings = GetObject <TLObject>(input) as TLPeerNotifySettingsBase;

            CustomFlags = GetNullableObject <TLLong>(input);

            return(this);
        }
Пример #25
0
        public override void Update(TLChatBase chat)
        {
            base.Update(chat);
            var c = chat as TLChatForbidden40;

            if (c != null)
            {
                if (c.CustomFlags != null)
                {
                    CustomFlags = c.CustomFlags;
                }
            }
        }
Пример #26
0
 protected static void SetField <T>(out T field, T value, ref TLLong flags, int flag) where T : TLObject
 {
     if (value != null)
     {
         Set(ref flags, flag);
         field = value;
     }
     else
     {
         Unset(ref flags, flag);
         field = null;
     }
 }
Пример #27
0
        protected static void Unset(ref TLLong flags, int flag)
        {
            var intFlag = flag;

            if (flags != null)
            {
                flags.Value &= ~intFlag;
            }
            else
            {
                flags = new TLLong(0);
            }
        }
Пример #28
0
        public override void Update(TLEncryptedChatBase chat)
        {
            base.Update(chat);

            var encryptedChat = chat as TLEncryptedChat20;

            if (encryptedChat != null)
            {
                PFS_ExchangeId     = encryptedChat.PFS_ExchangeId;
                PFS_A              = encryptedChat.PFS_A;
                PFS_Key            = encryptedChat.PFS_Key;
                PFS_KeyFingerprint = encryptedChat.PFS_KeyFingerprint;
            }
        }
Пример #29
0
        //public string SendingFileName { get; set; }
        //public byte[] Buffer { get; set; }
        //public byte[] Bytes { get; set; }
        #endregion

        public virtual void Update(TLFileLocationBase fileLocation)
        {
            if (fileLocation != null)
            {
                //if (Buffer == null || LocalId.Value != fileLocation.LocalId.Value)
                //{
                //    Buffer = fileLocation.Buffer;
                //}

                VolumeId = fileLocation.VolumeId;
                LocalId  = fileLocation.LocalId;
                Secret   = fileLocation.Secret;
            }
        }
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            Salt      = GetObject <TLLong>(bytes, ref position);
            SessionId = GetObject <TLLong>(bytes, ref position);

            MessageId         = GetObject <TLLong>(bytes, ref position);
            SeqNo             = GetObject <TLInt>(bytes, ref position);
            MessageDataLength = GetObject <TLInt>(bytes, ref position);
            MessageData       = GetObject <TLObject>(bytes, ref position);

            Debug.WriteLine("<<{3, -30} MsgId {0} SeqNo {2, 4} SessionId {1}", MessageId, SessionId, SeqNo, "message");

            return(this);
        }