public IEnumerable <ModeratorUser> GetModerators() { var request = WebAgent.CreateGet(string.Format(ModeratorsUrl, Name)); var response = request.GetResponse(); var responseString = WebAgent.GetResponseString(response.GetResponseStream()); var json = JObject.Parse(responseString); var type = json["kind"].ToString(); if (type != "UserList") { throw new FormatException("Reddit responded with an object that is not a user listing."); } var data = json["data"]; var mods = data["children"].ToArray(); var result = new ModeratorUser[mods.Length]; for (var i = 0; i < mods.Length; i++) { var mod = new ModeratorUser(Reddit, mods[i]); result[i] = mod; } return(result); }
public IEnumerable<ModeratorUser> GetModerators() { var request = WebAgent.CreateGet(string.Format(ModeratorsUrl, Name)); var response = request.GetResponse(); var responseString = WebAgent.GetResponseString(response.GetResponseStream()); var json = JObject.Parse(responseString); var type = json["kind"].ToString(); if (type != "UserList") throw new FormatException("Reddit responded with an object that is not a user listing."); var data = json["data"]; var mods = data["children"].ToArray(); var result = new ModeratorUser[mods.Length]; for (var i = 0; i < mods.Length; i++) { var mod = new ModeratorUser(Reddit, mods[i]); result[i] = mod; } return result; }