//返回消息时回调的方法 private void diaplayUser(Exception ee, byte[] response, object tag) { searchList.Items.Clear(); //反序列化返回的消息生成list ObjSerial<List<string>> se = new ObjSerial<List<string>>(); List<string> list=se.deserializeBytes(response); ChatListItem gp = new ChatListItem();//新建一个组 gp.Text = "查询结果"; gp.IsOpen = true; ChatListSubItemExtend user = new ChatListSubItemExtend(); //获取在线用户的ID foreach (string srtings in list) { //string的形式: //ID卍昵称卍性别卍生日卍地址卍注册时间 string[] userInfo = Regex.Split(srtings, Constant.SPLIT, RegexOptions.IgnoreCase); user.ID = Convert.ToUInt32(userInfo[0]); user.NicName = ""; user.DisplayName = userInfo[1]; if(userInfo[2]=="1") { user.Sex = ChatListSubItemExtend.UserSex.Man; } else if(userInfo[2]=="0") { user.Sex = ChatListSubItemExtend.UserSex.Women; } user.Birth = userInfo[3]; user.Address = userInfo[4]; user.RegistrationDate = userInfo[5]; gp.SubItems.Add(user); } this.searchList.Items.Add(gp); }
private void diaplayUser(Exception ee, byte[] response, object tag) { //反序列化返回的消息生成list ObjSerial<List<string>> se = new ObjSerial<List<string>>(); List<string> list = se.deserializeBytes(response); foreach (string srtings in list) { //string的形式:ID卍昵称卍性别卍生日卍地址卍注册时间 string[] userInfo = Regex.Split(srtings, Constant.SPLIT, RegexOptions.IgnoreCase); this.myInfo.NicName = userInfo[1]; this.myInfo.DisplayName = userInfo[1]; if (userInfo[2] == "1") { this.myInfo.Sex = ChatListSubItemExtend.UserSex.Man; } else if (userInfo[2] == "0") { this.myInfo.Sex = ChatListSubItemExtend.UserSex.Women; } this.myInfo.Birth = userInfo[3]; this.myInfo.Address = userInfo[4]; this.myInfo.RegistrationDate = userInfo[5]; lbl_userName.Text =myInfo.NicName +" "+ myInfo.ID.ToString(); } }