private static EmbeddedRepresentationBuilder Build(Subreddit subreddit) { var embeddedRepresentationBuilder = new EmbeddedRepresentationBuilder() .WithClass("subreddit") .WithRel("subreddit") .WithTitle(subreddit.Title) .WithProperty("domain", $"/r/{subreddit.DisplayName}") .WithProperty("subscribers", subreddit.Subscribers) .WithProperty("created", subreddit.Created) .WithProperty("description", subreddit.PublicDescription); return(embeddedRepresentationBuilder); }
protected SirenEntityBuilder SubEntity(T item) { var entity = new EmbeddedRepresentationBuilder() .WithClass(Class); AddEntityProperties(entity, item); AddEntitySubEntities(entity, item); AddEntityActions(entity, item); AddEntityLinks(entity, item); return(entity); }
private static void BuildCommentTree(Comment post, EmbeddedRepresentationBuilder builder) { foreach (var comment in post.Comments.Where(c => c.Kind != "more")) { var embeddedRepresentationBuilder = new EmbeddedRepresentationBuilder() .WithRel("comment") .WithProperty("author", comment.Author) .WithProperty("score", comment.Score) .WithProperty("created", comment.CreatedUTC) .WithTitle(comment.Body); BuildCommentTree(comment, embeddedRepresentationBuilder); builder.WithSubEntity(embeddedRepresentationBuilder); } }
private static EmbeddedRepresentationBuilder Build(Post post) { var embeddedRepresentationBuilder = new EmbeddedRepresentationBuilder() .WithClass("post") .WithRel("post") .WithTitle(post.Title) .WithProperty("score", post.Score) .WithProperty("subreddit", post.SubredditName) .WithProperty("comments", post.CommentCount) .WithProperty("submitted", post.CreatedUTC) .WithProperty("authorName", post.AuthorName) .WithProperty("domain", post.Domain) .WithProperty("linkFlairText", post.LinkFlairText) .WithLink(new LinkBuilder() .WithRel("self") .WithHref(post.Url.LocalPath)); if (post.Thumbnail.OriginalString != string.Empty) { embeddedRepresentationBuilder .WithProperty("url", post.Url); if (post.Thumbnail.OriginalString == "self" || post.Thumbnail.OriginalString == "nsfw" || post.Thumbnail.OriginalString == "default") { embeddedRepresentationBuilder .WithProperty("thumbnail", "/" + post.Thumbnail); } else { embeddedRepresentationBuilder .WithProperty("thumbnail", post.Thumbnail); } } return(embeddedRepresentationBuilder); }
public void SetUp() { _builder = new EmbeddedRepresentationBuilder(); }