public TLAbsUserStatus GetUserStatusFromChoosenListItem(int itemCollectionCount, int selectedIndex)
        {
            if (selectedIndex == itemCollectionCount - 1)
            {
                return(null);
            }

            try
            {
                var statuses = typeof(UserStatus).GetProperties();

                for (int i = 0; i < statuses.Length; i++)
                {
                    if (selectedIndex == i)
                    {
                        var             statusType = statuses[i].PropertyType;
                        TLAbsUserStatus instance   = (TLAbsUserStatus)Activator.CreateInstance(statusType);

                        return(instance);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(null);
        }
示例#2
0
文件: TLUser.cs 项目: hnjm/tgsharp
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     base.id    = StreamingUtils.readInt(stream);
     if ((this.flags & 1) != 0)
     {
         this.accessHash = StreamingUtils.readLong(stream);
     }
     if ((this.flags & 2) != 0)
     {
         this.firstName = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 4) != 0)
     {
         this.lastName = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 8) != 0)
     {
         this.userName = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x10) != 0)
     {
         this.phone = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x20) != 0)
     {
         this.photo = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x40) != 0)
     {
         this.status = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x4000) != 0)
     {
         this.botInfoVersion = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 0x40000) != 0)
     {
         this.restrictionReason = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x80000) != 0)
     {
         this.botInlinePlaceholder = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x200000) != 0)
     {
         this.langCode = StreamingUtils.readTLString(stream);
     }
 }
示例#3
0
        public UserSearchResult GetByUserStatus(UserSearchResult users, TLAbsUserStatus searchedStatus)
        {
            var result = new UserSearchResult()
            {
                TlUsers = new List <TLUser>(), Users = new List <UserModel>()
            };

            foreach (TLUser user in users.TlUsers)
            {
                TLAbsUserStatus actualStatus       = user.Status;
                var             searchedStatusName = searchedStatus.GetType().FullName;

                if (actualStatus.ToString() == searchedStatusName)
                {
                    result.TlUsers.Add(user);
                    result.Users.Add(_userService.CreateCustomUserModel(user));
                }
            }

            return(result);
        }
        public async Task <UserSearchResult> GetByUserStatus(TelegramClient client, List <TLUser> users, TLAbsUserStatus searchedStatus)
        {
            var result = new UserSearchResult()
            {
                TlUsers = new List <TLUser>(), Users = new List <UserModel>()
            };

            foreach (TLUser user in users)
            {
                TLAbsUserStatus actualStatus       = user.Status;
                var             searchedStatusName = searchedStatus.GetType().FullName;

                if (actualStatus.ToString() == searchedStatusName)
                {
                    var statusStr = searchedStatusName.Substring(14);
                    result.TlUsers.Add(user);
                    result.Users.Add(CreateCustomUser(user, userStatus: searchedStatusName.Substring(11))); //todo didn't check
                }
            }

            return(result);
        }
示例#5
0
 public override void DeserializeBody(BinaryReader br)
 {
     UserId = br.ReadInt32();
     Status = (TLAbsUserStatus)ObjectUtils.DeserializeObject(br);
 }
示例#6
0
 public virtual void setStatus(TLAbsUserStatus status)
 {
     this.status = status;
 }
示例#7
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.userId = StreamingUtils.readInt(stream);
     this.status = StreamingUtils.readTLObject(stream, context);
 }