0
|
1 using System;
|
|
2
|
|
3 namespace BLToolkit.Data.DataProvider
|
|
4 {
|
|
5 using Mapping;
|
|
6
|
|
7 public class FirebirdMappingSchema : MappingSchema
|
|
8 {
|
|
9 public byte[] ConvertToByteArray(string value)
|
|
10 {
|
|
11 return System.Text.Encoding.UTF8.GetBytes(value);
|
|
12 }
|
|
13
|
|
14 public override byte[] ConvertToByteArray(object value)
|
|
15 {
|
|
16 if (value is string)
|
|
17 return ConvertToByteArray((string)value);
|
|
18
|
|
19 return base.ConvertToByteArray(value);
|
|
20 }
|
|
21
|
|
22 public bool ConvertToBoolean(string value)
|
|
23 {
|
|
24 if (value.Length == 1)
|
|
25 switch (value[0])
|
|
26 {
|
|
27 case '1': case 'T' :case 'Y' : case 't': case 'y': return true;
|
|
28 case '0': case 'F' :case 'N' : case 'f': case 'n': return false;
|
|
29 }
|
|
30
|
|
31 return Common.Convert.ToBoolean(value);
|
|
32 }
|
|
33
|
|
34 public override bool ConvertToBoolean(object value)
|
|
35 {
|
|
36 if (value is string)
|
|
37 return ConvertToBoolean((string)value);
|
|
38
|
|
39 return base.ConvertToBoolean(value);
|
|
40 }
|
|
41
|
|
42 public System.IO.Stream ConvertToStream(string value)
|
|
43 {
|
|
44 return new System.IO.MemoryStream(ConvertToByteArray(value));
|
|
45 }
|
|
46
|
|
47 public override System.IO.Stream ConvertToStream(object value)
|
|
48 {
|
|
49 if (value is string)
|
|
50 return ConvertToStream((string)value);
|
|
51
|
|
52 return base.ConvertToStream(value);
|
|
53 }
|
|
54
|
|
55 #if !SILVERLIGHT
|
|
56
|
|
57 public System.Data.SqlTypes.SqlBinary ConvertToSqlBinary(string value)
|
|
58 {
|
|
59 return Common.Convert.ToSqlBinary(ConvertToByteArray(value));
|
|
60 }
|
|
61
|
|
62 public override System.Data.SqlTypes.SqlBinary ConvertToSqlBinary(object value)
|
|
63 {
|
|
64 if (value is string)
|
|
65 return ConvertToSqlBinary((string)value);
|
|
66 return base.ConvertToSqlBinary(value);
|
|
67 }
|
|
68
|
|
69 public System.Data.SqlTypes.SqlBytes ConvertToSqlBytes(string value)
|
|
70 {
|
|
71 return Common.Convert.ToSqlBytes(ConvertToByteArray(value));
|
|
72 }
|
|
73
|
|
74 public override System.Data.SqlTypes.SqlBytes ConvertToSqlBytes(object value)
|
|
75 {
|
|
76 if (value is string)
|
|
77 return ConvertToSqlBytes((string)value);
|
|
78
|
|
79 return base.ConvertToSqlBytes(value);
|
|
80 }
|
|
81
|
|
82 public override System.Data.SqlTypes.SqlGuid ConvertToSqlGuid(object value)
|
|
83 {
|
|
84 if (value is string)
|
|
85 return new System.Data.SqlTypes.SqlGuid(new Guid((string)value));
|
|
86 return base.ConvertToSqlGuid(value);
|
|
87 }
|
|
88
|
|
89 #endif
|
|
90
|
|
91 public override bool? ConvertToNullableBoolean(object value)
|
|
92 {
|
|
93 if (value is string)
|
|
94 return ConvertToBoolean((string)value);
|
|
95 return base.ConvertToNullableBoolean(value);
|
|
96 }
|
|
97 }
|
|
98 }
|