First actual commit
added sources to repository
This commit is contained in:
61
RedditSharp/Domain.cs
Normal file
61
RedditSharp/Domain.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RedditSharp.Things;
|
||||
|
||||
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; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Name { get; set; }
|
||||
|
||||
public Listing<Post> Posts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Listing<Post>(Reddit, string.Format(DomainPostUrl, Name), WebAgent);
|
||||
}
|
||||
}
|
||||
|
||||
public Listing<Post> New
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Listing<Post>(Reddit, string.Format(DomainNewUrl, Name), WebAgent);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "/domain/" + Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user