@@ -36,7 +36,7 @@ public class Reddit
36
36
private const string PopularSubredditsUrl = "/subreddits/popular.json" ;
37
37
private const string GoldSubredditsUrl = "/subreddits/gold.json" ;
38
38
private const string DefaultSubredditsUrl = "/subreddits/default.json" ;
39
- private const string SearchSubredditsUrl = "/subreddits/search.json?q={0}" ;
39
+ private const string SearchSubredditsUrl = "/subreddits/search.json?q={0}" ;
40
40
41
41
42
42
#endregion
@@ -129,35 +129,35 @@ public Reddit(string accessToken)
129
129
WebAgent . AccessToken = accessToken ;
130
130
InitOrUpdateUser ( ) ;
131
131
}
132
- /// <summary>
133
- /// Creates a Reddit instance with the given WebAgent implementation
134
- /// </summary>
132
+ /// <summary>
133
+ /// Creates a Reddit instance with the given WebAgent implementation
134
+ /// </summary>
135
135
/// <param name="agent">Implementation of IWebAgent interface. Used to generate requests.</param>
136
- public Reddit ( IWebAgent agent )
137
- {
138
- WebAgent = agent ;
139
- JsonSerializerSettings = new JsonSerializerSettings
140
- {
141
- CheckAdditionalContent = false ,
142
- DefaultValueHandling = DefaultValueHandling . Ignore
136
+ public Reddit ( IWebAgent agent )
137
+ {
138
+ WebAgent = agent ;
139
+ JsonSerializerSettings = new JsonSerializerSettings
140
+ {
141
+ CheckAdditionalContent = false ,
142
+ DefaultValueHandling = DefaultValueHandling . Ignore
143
143
} ;
144
- CaptchaSolver = new ConsoleCaptchaSolver ( ) ;
144
+ CaptchaSolver = new ConsoleCaptchaSolver ( ) ;
145
145
}
146
- /// <summary>
147
- /// Creates a Reddit instance with the given WebAgent implementation
148
- /// </summary>
146
+ /// <summary>
147
+ /// Creates a Reddit instance with the given WebAgent implementation
148
+ /// </summary>
149
149
/// <param name="agent">Implementation of IWebAgent interface. Used to generate requests.</param>
150
150
/// <param name="initUser">Whether to run InitOrUpdateUser, requires <paramref name="agent"/> to have credentials first.</param>
151
- public Reddit ( IWebAgent agent , bool initUser )
152
- {
153
- WebAgent = agent ;
154
- JsonSerializerSettings = new JsonSerializerSettings
155
- {
156
- CheckAdditionalContent = false ,
157
- DefaultValueHandling = DefaultValueHandling . Ignore
151
+ public Reddit ( IWebAgent agent , bool initUser )
152
+ {
153
+ WebAgent = agent ;
154
+ JsonSerializerSettings = new JsonSerializerSettings
155
+ {
156
+ CheckAdditionalContent = false ,
157
+ DefaultValueHandling = DefaultValueHandling . Ignore
158
158
} ;
159
- CaptchaSolver = new ConsoleCaptchaSolver ( ) ;
160
- if ( initUser ) InitOrUpdateUser ( ) ;
159
+ CaptchaSolver = new ConsoleCaptchaSolver ( ) ;
160
+ if ( initUser ) InitOrUpdateUser ( ) ;
161
161
}
162
162
163
163
/// <summary>
@@ -401,18 +401,18 @@ public Listing<T> Search<T>(string query, Sorting sortE = Sorting.Relevance, Tim
401
401
string sort = sortE . ToString ( ) . ToLower ( ) ;
402
402
string time = timeE . ToString ( ) . ToLower ( ) ;
403
403
return new Listing < T > ( this , string . Format ( SearchUrl , query , sort , time ) , WebAgent ) ;
404
- }
405
-
406
- public Listing < T > SearchByTimestamp < T > ( DateTime from , DateTime to , string query = "" , string subreddit = "" , Sorting sortE = Sorting . Relevance , TimeSorting timeE = TimeSorting . All ) where T : Thing
407
- {
408
- string sort = sortE . ToString ( ) . ToLower ( ) ;
409
- string time = timeE . ToString ( ) . ToLower ( ) ;
410
-
411
- var fromUnix = ( from - new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 ) ) . TotalSeconds ;
412
- var toUnix = ( to - new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 ) ) . TotalSeconds ;
413
-
414
- string searchQuery = "(and+timestamp:" + fromUnix + ".." + toUnix + "+'" + query + "'+" + "subreddit:'" + subreddit + "')&syntax=cloudsearch" ;
415
- return new Listing < T > ( this , string . Format ( SearchUrl , searchQuery , sort , time ) , WebAgent ) ;
404
+ }
405
+
406
+ public Listing < T > SearchByTimestamp < T > ( DateTime from , DateTime to , string query = "" , string subreddit = "" , Sorting sortE = Sorting . Relevance , TimeSorting timeE = TimeSorting . All ) where T : Thing
407
+ {
408
+ string sort = sortE . ToString ( ) . ToLower ( ) ;
409
+ string time = timeE . ToString ( ) . ToLower ( ) ;
410
+
411
+ var fromUnix = ( from - new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 ) ) . TotalSeconds ;
412
+ var toUnix = ( to - new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 ) ) . TotalSeconds ;
413
+
414
+ string searchQuery = "(and+timestamp:" + fromUnix + ".." + toUnix + "+'" + query + "'+" + "subreddit:'" + subreddit + "')&syntax=cloudsearch" ;
415
+ return new Listing < T > ( this , string . Format ( SearchUrl , searchQuery , sort , time ) , WebAgent ) ;
416
416
}
417
417
418
418
#region SubredditSearching
@@ -451,15 +451,15 @@ public Listing<Subreddit> GetGoldSubreddits()
451
451
public Listing < Subreddit > GetDefaultSubreddits ( )
452
452
{
453
453
return new Listing < Subreddit > ( this , DefaultSubredditsUrl , WebAgent ) ;
454
- }
455
-
456
- /// <summary>
457
- /// Returns the Listing of subreddits related to a query.
458
- /// </summary>
459
- /// <returns></returns>
460
- public Listing < Subreddit > SearchSubreddits ( string query )
461
- {
462
- return new Listing < Subreddit > ( this , string . Format ( SearchSubredditsUrl , query ) , WebAgent ) ;
454
+ }
455
+
456
+ /// <summary>
457
+ /// Returns the Listing of subreddits related to a query.
458
+ /// </summary>
459
+ /// <returns></returns>
460
+ public Listing < Subreddit > SearchSubreddits ( string query )
461
+ {
462
+ return new Listing < Subreddit > ( this , string . Format ( SearchSubredditsUrl , query ) , WebAgent ) ;
463
463
}
464
464
465
465
#endregion SubredditSearching
0 commit comments