File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
src/Nest/CommonAbstractions/LazyDocument Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
- using Newtonsoft . Json ;
1
+ using System ;
2
+ using Newtonsoft . Json ;
2
3
using Newtonsoft . Json . Linq ;
3
4
4
5
namespace Nest
@@ -7,22 +8,37 @@ namespace Nest
7
8
public interface ILazyDocument
8
9
{
9
10
/// <summary>
10
- ///
11
+ /// Creates an instance of <typeparamref name="T"/> from this
12
+ /// <see cref="ILazyDocument"/> instance
11
13
/// </summary>
12
- /// <typeparam name="T"></typeparam>
13
- /// <returns></returns>
14
+ /// <typeparam name="T">The type</typeparam>
14
15
T As < T > ( ) where T : class ;
16
+
17
+ /// <summary>
18
+ /// Creates an instance of <paramref name="objectType"/> from this
19
+ /// <see cref="ILazyDocument"/> instance
20
+ /// </summary>
21
+ /// <typeparam name="T">The type</typeparam>
22
+ object As ( Type objectType ) ;
15
23
}
16
24
17
25
public class LazyDocument : ILazyDocument
18
26
{
19
27
internal JToken _Value { get ; set ; }
20
28
internal JsonSerializer _Serializer { get ; set ; }
21
29
30
+ /// <inheritdoc />
22
31
public T As < T > ( ) where T : class
23
32
{
24
33
var jToken = this . _Value ;
25
34
return jToken ? . ToObject < T > ( _Serializer ) ;
26
35
}
36
+
37
+ /// <inheritdoc />
38
+ public object As ( Type objectType )
39
+ {
40
+ var jToken = this . _Value ;
41
+ return jToken ? . ToObject ( objectType , _Serializer ) ;
42
+ }
27
43
}
28
44
}
You can’t perform that action at this time.
0 commit comments