예제 #1
4
        public Comment(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
            : base(reddit, webAgent, json)
        {
            var data = json["data"];
            JsonConvert.PopulateObject(data.ToString(), this, reddit.JsonSerializerSettings);
            Reddit = reddit;
            WebAgent = webAgent;

            // Parse sub comments
            // TODO: Consider deserializing this properly
            var subComments = new List<Comment>();
            if (data["replies"] != null && data["replies"].Any())
            {
                foreach (var comment in data["replies"]["data"]["children"])
                    subComments.Add(new Comment(reddit, comment, webAgent, sender));
            }
            Comments = subComments.ToArray();

            this.Parent = sender;

            // Handle Reddit's API being horrible
            if (data["context"] != null)
            {
                var context = data["context"].Value<string>();
                LinkId = context.Split('/')[4];
            }
        }
예제 #2
0
 public void Reset()
 {
     After            = Before = null;
     CurrentPageIndex = -1;
     CurrentPage      = new Thing[0];
 }