private Comment parseComments(RedditObject obj) { RedditData data = obj.data; Comment comment = new Comment(); comment.name = data.author; comment.commentTime = data.created_utc; comment.body = data.body; if (data.replies != null) { foreach (var item in data.replies.data.children) { Comment subComment = parseComments(item); if (subComment != null) { comment.replies.Add(subComment); } } } return comment; }
// Handle single comments HTML void ParseComment(Comment comment) { CommentCount++; // Read comment info Redditor red = new Redditor(); red.Name = comment.name; red.PostTime = comment.commentTime; red.CommentText = comment.body; // Clean up red.PostTime = red.PostTime.Replace(" ", " "); // Made edits more visible if (red.PostTime.Contains("*") || red.PostTime.Contains("*")) { red.PostTime = red.PostTime.Replace("*", "*(EDITED!!!)"); red.PostTime = red.PostTime.Replace("*", "*(EDITED!!!)"); red.Edited = true; } red.ExtraComment = ""; // Try to parse the comments content if (red.ParseGTGComment()) parseResults.Add(red); else failedComments.Add(red); foreach (var item in comment.replies) { ParseComment(item); } }