Example #1
0
File: Link.cs Project: gwely/Reddit
 /// <summary>
 ///
 /// </summary>
 /// <param name="Sort">one of: SortBy.Hot, SortBy.New, SortBy.Old, SortBy.Top, SortBy.Controversial</param>
 /// <returns></returns>
 public List<Comment> GetComments(SortBy Sort = null)
 {
     if (Sort == null)
     {
         Sort = SortBy.Hot;
     }
     if (Sort == SortBy.Best || Sort == SortBy.Old)
     {
         throw new Exception("Can't apply SortBy.Best or SortBy.Old in this context");
     }
     string Response = Connection.Get("comments/" + ID + ".json", "sort=" + Sort.Arg);
     var Comments = new List<Comment>();
     foreach (var Comment in SimpleJSON.JSONDecoder.Decode(Response)[1]["data"]["children"].ArrayValue)
     {
         var CommentObj = API.Comment.Create(Comment["data"]);
         CommentObj._Link = this;
         Comments.Add(CommentObj);
     }
     return Comments;
 }
Example #2
0
File: User.cs Project: gwely/Reddit
 /// <summary>
 ///
 /// </summary>
 /// <param name="Sort">one of: SortBy.Hot, SortBy.New, SortBy.Top, SortBy.Controversial</param>
 /// <param name="From">one of: From.ThisHour, From.Today, From.ThisWeek, From.ThisMonth, From.ThisYear, From.Forever</param>
 /// <returns></returns>
 public List<Comment> GetComments(SortBy Sort = null, From From = null)
 {
     if (Sort == null)
     {
         Sort = SortBy.Hot;
     }
     if (From == null)
     {
         From = Enums.From.AllTime;
     }
     if (Sort == SortBy.Best || Sort == SortBy.Old)
     {
         throw new Exception("Can't apply SortBy.Best or SortBy.Old in this context");
     }
     string Response = Connection.Get("user/" + Name + "/comments.json", "sort=" + Sort.Arg + "&t=" + From.Arg);
     var Comments = new List<Comment>();
     foreach (var Comment in SimpleJSON.JSONDecoder.Decode(Response)["data"]["children"].ArrayValue)
     {
         Comments.Add(API.Comment.Create(Comment["data"]));
     }
     return Comments;
 }