@@ -14,27 +14,41 @@ public class DefaultConverters
14
14
public void RegisterDefault ( LightningEnvironment environment )
15
15
{
16
16
var store = environment . ConverterStore ;
17
- store . AddConvertToBytes < int > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
18
- store . AddConvertToBytes < string > ( ( db , x ) => db . Encoding . GetBytes ( x ) ) ;
17
+
18
+ store . AddConvertToBytes < Guid > ( ( db , x ) => x . ToByteArray ( ) ) ;
19
+ store . AddConvertToBytes < Double > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
20
+ store . AddConvertToBytes < Single > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
21
+ store . AddConvertToBytes < Boolean > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
22
+ store . AddConvertToBytes < Int16 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
23
+ store . AddConvertToBytes < Int32 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
24
+ store . AddConvertToBytes < Int64 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
25
+ store . AddConvertToBytes < UInt16 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
26
+ store . AddConvertToBytes < UInt32 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
27
+ store . AddConvertToBytes < UInt64 > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
28
+ store . AddConvertToBytes < Char > ( ( db , x ) => BitConverter . GetBytes ( x ) ) ;
29
+ store . AddConvertToBytes < Byte > ( ( db , x ) => new [ ] { x } ) ;
30
+ store . AddConvertToBytes < SByte > ( ( db , x ) => new [ ] { ( byte ) x } ) ;
31
+ store . AddConvertToBytes < String > ( ( db , x ) => db . Encoding . GetBytes ( x ) ) ;
19
32
store . AddConvertToBytes < byte [ ] > ( ( db , x ) => x ) ;
20
33
21
- convertFromBytesWithCorrectSize ( store , ( db , x ) => new Guid ( x ) , 16 ) ;
22
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToDouble ( x , 0 ) ) ;
23
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToSingle ( x , 0 ) ) ;
24
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToBoolean ( x , 0 ) ) ;
25
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt16 ( x , 0 ) ) ;
26
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt32 ( x , 0 ) ) ;
27
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt64 ( x , 0 ) ) ;
28
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt16 ( x , 0 ) ) ;
29
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt32 ( x , 0 ) ) ;
30
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt64 ( x , 0 ) ) ;
31
- convertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToChar ( x , 0 ) ) ;
32
- convertFromBytesWithCorrectSize ( store , ( db , x ) => x [ 0 ] ) ;
33
- convertFromBytesWithCorrectSize ( store , ( db , x ) => ( SByte ) x [ 0 ] ) ;
34
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => new Guid ( x ) , 16 ) ;
35
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToDouble ( x , 0 ) ) ;
36
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToSingle ( x , 0 ) ) ;
37
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToBoolean ( x , 0 ) ) ;
38
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt16 ( x , 0 ) ) ;
39
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt32 ( x , 0 ) ) ;
40
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToInt64 ( x , 0 ) ) ;
41
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt16 ( x , 0 ) ) ;
42
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt32 ( x , 0 ) ) ;
43
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToUInt64 ( x , 0 ) ) ;
44
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => BitConverter . ToChar ( x , 0 ) ) ;
45
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => x [ 0 ] ) ;
46
+ ConvertFromBytesWithCorrectSize ( store , ( db , x ) => ( SByte ) x [ 0 ] ) ;
34
47
store . AddConvertFromBytes ( ( db , x ) => db . Encoding . GetString ( x ) ) ;
48
+ store . AddConvertFromBytes ( ( db , x ) => x ) ;
35
49
}
36
50
37
- private void convertFromBytesWithCorrectSize < TTo > ( ConverterStore store , Func < LightningDatabase , byte [ ] , TTo > convert , int ? size = null ) where TTo : struct
51
+ private void ConvertFromBytesWithCorrectSize < TTo > ( ConverterStore store , Func < LightningDatabase , byte [ ] , TTo > convert , int ? size = null ) where TTo : struct
38
52
{
39
53
var func = convert . EnsureCorrectSize ( size ) ;
40
54
store . AddConvertFromBytes ( func ) ;
0 commit comments