This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ public static T ConvertTo<T>(this object from)
42
42
return to . PopulateWith ( from ) ;
43
43
}
44
44
45
+ public static To ThenDo < To > ( this To to , Action < To > fn )
46
+ {
47
+ fn ( to ) ;
48
+ return to ;
49
+ }
50
+
45
51
public static object ConvertTo ( this object from , Type type )
46
52
{
47
53
if ( from == null )
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Reflection ;
4
+ using System . Threading . Tasks ;
4
5
5
6
namespace ServiceStack . Text
6
7
{
7
8
public static class TypeConstants
8
9
{
10
+ static TypeConstants ( )
11
+ {
12
+ ZeroTask = InTask ( 0 ) ;
13
+ TrueTask = InTask ( true ) ;
14
+ FalseTask = InTask ( false ) ;
15
+ EmptyTask = InTask ( ( object ) null ) ;
16
+ }
17
+
18
+ private static Task < T > InTask < T > ( this T result )
19
+ {
20
+ var tcs = new TaskCompletionSource < T > ( ) ;
21
+ tcs . SetResult ( result ) ;
22
+ return tcs . Task ;
23
+ }
24
+
25
+ public static readonly Task < int > ZeroTask ;
26
+ public static readonly Task < bool > TrueTask ;
27
+ public static readonly Task < bool > FalseTask ;
28
+ public static readonly Task < object > EmptyTask ;
29
+
30
+ public static readonly object EmptyObject = new object ( ) ;
31
+
9
32
public static readonly string [ ] EmptyStringArray = new string [ 0 ] ;
10
33
public static readonly long [ ] EmptyLongArray = new long [ 0 ] ;
11
34
public static readonly int [ ] EmptyIntArray = new int [ 0 ] ;
You can’t perform that action at this time.
0 commit comments