Esempio n. 1
0
 /// <summary>
 /// Create a new comment controller instance, populated only with its fullname.
 /// </summary>
 /// <param name="dispatch"></param>
 /// <param name="fullname">Fullname of the comment</param>
 public Comment(Dispatch dispatch, string fullname)
 {
     Dispatch = dispatch;
     Listing  = new Things.Comment {
         Name = fullname
     };
 }
Esempio n. 2
0
        private void Import(string subreddit, string author, string body, string bodyHtml,
                            string parentFullname  = null, string collapsedReason  = null, bool collapsed        = false, bool isSubmitter = false,
                            List <Comment> replies = null, List <Things.More> more = null, bool scoreHidden      = false, int depth        = 0, string id = null, string fullname = null,
                            string permalink       = null, DateTime created = default(DateTime), DateTime edited = default(DateTime),
                            int score = 0, int upVotes = 0, int downVotes = 0, bool removed = false, bool spam = false)
        {
            Listing = new Things.Comment
            {
                Subreddit       = subreddit,
                Author          = author,
                Body            = body,
                BodyHTML        = bodyHtml,
                ParentId        = parentFullname,
                CollapsedReason = collapsedReason,
                Collapsed       = collapsed,
                IsSubmitter     = isSubmitter,
                ScoreHidden     = scoreHidden,
                Depth           = depth,
                Id         = id,
                Name       = fullname,
                Permalink  = permalink,
                CreatedUTC = created,
                Edited     = edited,
                Score      = score,
                Ups        = upVotes,
                Downs      = downVotes,
                Removed    = removed,
                Spam       = spam
            };

            More    = (more == null && Listing.Replies != null ? Listing.Replies.MoreData : (more ?? new List <Things.More>()));
            Replies = (replies == null && Listing.Replies != null ? Lists.GetComments(Listing.Replies.Comments, Dispatch) : (replies ?? new List <Comment>()));
        }
Esempio n. 3
0
        private void Import(string subreddit, string author, string body, string bodyHtml,
                            string parentFullname  = null, string collapsedReason  = null, bool collapsed        = false, bool isSubmitter = false,
                            List <Comment> replies = null, List <Things.More> more = null, bool scoreHidden      = false, int depth        = 0, string id = null, string fullname = null,
                            string permalink       = null, DateTime created = default(DateTime), DateTime edited = default(DateTime),
                            int score = 0, int upVotes = 0, int downVotes = 0, bool removed = false, bool spam = false)
        {
            Subreddit       = subreddit;
            Author          = author;
            Body            = body;
            BodyHTML        = bodyHtml;
            ParentFullname  = parentFullname;
            ParentId        = (!string.IsNullOrEmpty(ParentFullname) && (ParentFullname.StartsWith("t3_") || ParentFullname.StartsWith("t1_")) ? ParentFullname.Substring(3) : null);
            CollapsedReason = collapsedReason;
            Collapsed       = collapsed;
            IsSubmitter     = isSubmitter;
            Replies         = replies;
            More            = more;
            ScoreHidden     = scoreHidden;
            Depth           = depth;
            Id        = id;
            Fullname  = fullname;
            Permalink = permalink;
            Created   = created;
            Edited    = edited;
            Score     = score;
            UpVotes   = upVotes;
            DownVotes = downVotes;
            Removed   = removed;
            Spam      = spam;

            Awards = new Awards();

            Listing = new Things.Comment(this);
        }
Esempio n. 4
0
        private void Import(Things.Comment listing)
        {
            Subreddit       = listing.Subreddit;
            Author          = listing.Author;
            Body            = listing.Body;
            BodyHTML        = listing.BodyHTML;
            ParentFullname  = listing.ParentId;
            ParentId        = (!string.IsNullOrEmpty(ParentFullname) && ParentFullname.StartsWith("t3_") ? ParentFullname.Substring(3) : null);
            CollapsedReason = listing.CollapsedReason;
            Collapsed       = listing.Collapsed;
            IsSubmitter     = listing.IsSubmitter;
            Replies         = (listing.Replies != null ? Lists.GetComments(listing.Replies.Comments, Dispatch) : new List <Comment>());
            More            = (listing.Replies != null ? listing.Replies.MoreData : new List <Things.More>());
            ScoreHidden     = listing.ScoreHidden;
            Depth           = listing.Depth;
            Id        = listing.Id;
            Fullname  = listing.Name;
            Permalink = listing.Permalink;
            Created   = listing.CreatedUTC;
            Edited    = listing.Edited;
            Score     = listing.Score;
            UpVotes   = listing.Ups;
            DownVotes = listing.Downs;
            Removed   = listing.Removed;
            Spam      = listing.Spam;

            Awards = new Awards(listing);

            Listing = listing;
        }
Esempio n. 5
0
        private void Import(Things.Comment listing)
        {
            Body     = listing.Body;
            BodyHTML = listing.BodyHTML;
            Replies  = (listing.Replies != null ? Lists.GetComments(listing.Replies.Comments, Dispatch) : new List <Comment>());
            More     = (listing.Replies != null ? listing.Replies.MoreData : new List <Things.More>());

            Listing = listing;
        }
Esempio n. 6
0
 /// <summary>
 /// Initialize the Awards controller from a comment.
 /// </summary>
 /// <param name="post">A valid Things.Comment instance</param>
 public Awards(Things.Comment comment)
 {
     if (comment.Gildings != null)
     {
         Silver   = (comment.Gildings.ContainsKey("gid_1") ? comment.Gildings["gid_1"] : 0);
         Gold     = (comment.Gildings.ContainsKey("gid_2") ? comment.Gildings["gid_2"] : 0);
         Platinum = (comment.Gildings.ContainsKey("gid_3") ? comment.Gildings["gid_3"] : 0);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Create a new comment controller instance from API return data.
 /// </summary>
 /// <param name="dispatch"></param>
 /// <param name="listing"></param>
 public Comment(Dispatch dispatch, Things.Comment listing)
 {
     Dispatch = dispatch;
     Import(listing);
 }