/
Subreddit.cs
99 lines (90 loc) · 3.22 KB
/
Subreddit.cs
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using SnooSharp.Converters;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace SnooSharp
{
[DataContract]
public class Subreddit : ThingData, ICreated
{
public Subreddit() { }
public Subreddit(string target)
{
var displayName = target.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault();
Description = "not loaded yet";
DisplayName = string.IsNullOrWhiteSpace(displayName) ? "front page" : displayName;
Over18 = false;
Subscribers = 1;
Title = DisplayName;
Url = target;
HeaderImage = "http://www.redditstatic.com/icon.png";
PublicDescription = Description;
Headertitle = DisplayName;
if (target == "/")
Id = "";
}
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("display_name")]
public string DisplayName { get; set; }
[JsonProperty("over18")]
public bool? Over18 { get; set; }
[JsonProperty("subscribers", NullValueHandling=NullValueHandling.Ignore)]
public long Subscribers { get; set; }
[JsonProperty("user_is_subscriber", NullValueHandling = NullValueHandling.Ignore)]
public bool Subscribed { get; set; }
[JsonProperty("user_is_moderator", NullValueHandling = NullValueHandling.Ignore)]
public bool Moderator { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonConverter(typeof(UnixTimeConverter))]
[JsonProperty("created")]
public DateTime Created { get; set; }
[JsonConverter(typeof(UnixUTCTimeConverter))]
[JsonProperty("created_utc")]
public DateTime CreatedUTC { get; set; }
[JsonProperty("header_img")]
public string HeaderImage { get; set; }
[JsonProperty("header_size")]
public int[] HeaderSize { get; set; }
[JsonProperty("public_description")]
public string PublicDescription { get; set; }
[JsonProperty("header_title")]
public string Headertitle { get; set; }
}
[DataContract]
public class LabeledMulti : ThingData
{
[JsonProperty("path")]
public string Path { get; set; }
[JsonProperty("visibility")]
public string Visibility { get; set; }
[JsonProperty("can_edit")]
public string CanEdit { get; set; }
[JsonConverter(typeof(UnixUTCTimeConverter))]
[JsonProperty("created")]
public DateTime Created { get; set; }
[JsonProperty("subreddits")]
public List<LabeledMultiSubredditItem> Subreddits { get; set; }
}
[DataContract]
public class LabeledMultiSubredditItem
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("data")]
public Subreddit Data { get; set; }
}
[DataContract]
public class LabeledMultiDescription : ThingData
{
[JsonProperty("body_md")]
public string BodyMD { get; set; }
}
}