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)
4242 return to . PopulateWith ( from ) ;
4343 }
4444
45+ public static To ThenDo < To > ( this To to , Action < To > fn )
46+ {
47+ fn ( to ) ;
48+ return to ;
49+ }
50+
4551 public static object ConvertTo ( this object from , Type type )
4652 {
4753 if ( from == null )
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . Reflection ;
4+ using System . Threading . Tasks ;
45
56namespace ServiceStack . Text
67{
78 public static class TypeConstants
89 {
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+
932 public static readonly string [ ] EmptyStringArray = new string [ 0 ] ;
1033 public static readonly long [ ] EmptyLongArray = new long [ 0 ] ;
1134 public static readonly int [ ] EmptyIntArray = new int [ 0 ] ;
You can’t perform that action at this time.
0 commit comments