public static ResultPerPageFree FromObjectInstance(Jurassic.Library.ObjectInstance instance) { /*为了简单,省去1万地反射...*/ var ret = new ResultPerPageFree(); foreach (var pi in ret.GetType().GetProperties()) { try { var value = instance.GetPropertyValue(JsonPropertyName(pi)); if (pi.Name == "GroupsList") { var ls = value as ArrayInstance; if (ls != null) { var wxGroups = (from ObjectInstance o in ls.ElementValues select FromObject <WxGroup>(o)).ToList(); pi.SetValue(ret, wxGroups, null); } } else if (pi.Name == "FriendsList") { var ls = value as ArrayInstance; if (ls != null) { var wxGroups = (from ObjectInstance o in ls.ElementValues select FromObject <WxUserFree>(o)).ToList(); pi.SetValue(ret, wxGroups, null); } } else { pi.SetValue(ret, Convert.ChangeType(value, pi.PropertyType), null); } } catch { } } return(ret); }
private ResultPerPageFree InnerUserList(string token, int pageSize, int pageIndex) { var dic = new Dictionary <string, object> { { "t", "user/index" }, { "pagesize", pageSize }, { "pageidx", pageIndex }, { "type", "0" }, { "groupid", GroupId }, { "token", token }, { "lang", Language }, }; //var s = HttpHelper.GetString(DefaultUserListUrl, dic, _cc, null); var stream = HttpExtendedHelper.Get(DefaultUserListUrl, dic, _cc, null); var doc = new HtmlDocument(); doc.Load(stream, Encoding); var ss = doc.DocumentNode.SelectNodes("//script"); var se = new Jurassic.ScriptEngine(); foreach (var s in ss.Where(e => e.GetAttributeValue("src", string.Empty).Equals(string.Empty))) { try { se.Execute("if(typeof(wx)=='undefined') wx={}"); se.Execute(s.InnerText); } catch { // se.Execute("if(!wxwx.cgiData)delete wx"); } } var temp = se.GetGlobalValue("wx") as Jurassic.Library.ObjectInstance; var r = ResultPerPageFree.FromObjectInstance(temp.GetPropertyValue("cgiData") as ObjectInstance); return(r); }