forked from CrustyJew/RedditSharp-DEPRECATED-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomain.cs
More file actions
73 lines (63 loc) · 1.93 KB
/
Domain.cs
File metadata and controls
73 lines (63 loc) · 1.93 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
using Newtonsoft.Json;
using RedditSharp.Things;
using System;
namespace RedditSharp
{
public class Domain
{
private const string DomainPostUrl = "/domain/{0}.json";
private const string DomainNewUrl = "/domain/{0}/new.json?sort=new";
private const string DomainHotUrl = "/domain/{0}/hot.json";
private const string FrontPageUrl = "/.json";
[JsonIgnore]
private Reddit Reddit { get; set; }
[JsonIgnore]
private IWebAgent WebAgent { get; set; }
/// <summary>
/// Domain name
/// </summary>
[JsonIgnore]
public string Name { get; set; }
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain.
/// </summary>
public Listing<Post> Posts
{
get
{
return new Listing<Post>(Reddit, string.Format(DomainPostUrl, Name), WebAgent);
}
}
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain that are in the new queue.
/// </summary>
public Listing<Post> New
{
get
{
return new Listing<Post>(Reddit, string.Format(DomainNewUrl, Name), WebAgent);
}
}
/// <summary>
/// Get a <see cref="Listing{T}"/> of posts made for this domain that are in the hot queue.
/// </summary>
public Listing<Post> Hot
{
get
{
return new Listing<Post>(Reddit, string.Format(DomainHotUrl, Name), WebAgent);
}
}
protected internal Domain(Reddit reddit, Uri domain, IWebAgent webAgent)
{
Reddit = reddit;
WebAgent = webAgent;
Name = domain.Host;
}
/// <inheritdoc/>
public override string ToString()
{
return "/domain/" + Name;
}
}
}