@@ -10,7 +10,7 @@ namespace RedditSharp.Things
10
10
/// </summary>
11
11
public class Thing : RedditObject
12
12
{
13
-
13
+
14
14
#region Properties
15
15
16
16
/// <summary>
@@ -42,6 +42,16 @@ public class Thing : RedditObject
42
42
/// Gets the time since last fetch from reddit servers.
43
43
/// </summary>
44
44
public TimeSpan TimeSinceFetch => DateTime . Now - FetchedAt ;
45
+
46
+ private JToken RawJson { get ; set ; }
47
+
48
+ /// <summary>
49
+ /// Gets a property of this Thing, without any automatic conversion.
50
+ /// </summary>
51
+ /// <param name="property">The reddit API name of the property</param>
52
+ /// <returns>The property's value as a <see cref="String"/> or null if the property
53
+ /// doesn't exist or is null.</returns>
54
+ public String this [ String property ] => RawJson [ property ] . ValueOrDefault < string > ( ) ;
45
55
#endregion
46
56
47
57
@@ -68,6 +78,7 @@ internal void Populate(JToken json)
68
78
FullName = data [ "name" ] . ValueOrDefault < string > ( ) ;
69
79
Id = data [ "id" ] . ValueOrDefault < string > ( ) ;
70
80
Kind = json [ "kind" ] . ValueOrDefault < string > ( ) ;
81
+ RawJson = data ;
71
82
FetchedAt = DateTime . Now ;
72
83
Helpers . PopulateObject ( GetJsonData ( json ) , this ) ;
73
84
}
@@ -177,8 +188,10 @@ protected virtual async Task<JToken> SimpleActionAsync(string endpoint)
177
188
/// <param name="fullname">FullName of thing to act on. eg. t1_66666</param>
178
189
/// <param name="endpoint">URL to post to</param>
179
190
/// <returns></returns>
180
- protected static Task < JToken > SimpleActionAsync ( IWebAgent agent , string fullname , string endpoint ) {
181
- return agent . Post ( endpoint , new {
191
+ protected static Task < JToken > SimpleActionAsync ( IWebAgent agent , string fullname , string endpoint )
192
+ {
193
+ return agent . Post ( endpoint , new
194
+ {
182
195
id = fullname
183
196
} ) ;
184
197
}
0 commit comments