-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathPost.cs
More file actions
78 lines (71 loc) · 2.5 KB
/
Post.cs
File metadata and controls
78 lines (71 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace MvvmSample.Models
{
/// <summary>
/// A class for a query for posts in a given subreddit.
/// </summary>
public class PostsQueryResponse
{
/// <summary>
/// Gets or sets the listing data for the response.
/// </summary>
[JsonProperty("data")]
public PostListing Data { get; set; }
}
/// <summary>
/// A class for a Reddit listing of posts.
/// </summary>
public class PostListing
{
/// <summary>
/// Gets or sets the items in this listing.
/// </summary>
[JsonProperty("children")]
public IList<PostData> Items { get; set; }
}
/// <summary>
/// A wrapping class for a post.
/// </summary>
public class PostData
{
/// <summary>
/// Gets or sets the <see cref="Post"/> instance.
/// </summary>
[JsonProperty("data")]
public Post Data { get; set; }
}
/// <summary>
/// A simple model for a Reddit post.
/// </summary>
public class Post
{
/// <summary>
/// Gets or sets the title of the post.
/// </summary>
[JsonProperty("title")]
public string Title { get; set; }
/// <summary>
/// Gets or sets the URL to the post thumbnail, if present.
/// </summary>
[JsonProperty("thumbnail")]
public string Thumbnail { get; set; }
/// <summary>
/// Gets the text of the post.
/// </summary>
/// <remarks>
/// Here we're just hardcoding some sample text to simplify how posts are displayed.
/// Normally, not all posts have a self text post available.
/// </remarks>
[JsonIgnore]
public string SelfText { get; } = string.Join(" ", Enumerable.Repeat(
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", 20));
}
}