Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DefaultValueTypeConverter.cs
Go to the documentation of this file.
3
4namespace System.Data;
5
7{
8 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
9 {
10 if (destinationType == null)
11 {
12 throw new ArgumentNullException("destinationType");
13 }
14 if (destinationType == typeof(string))
15 {
16 if (value == null)
17 {
18 return "<null>";
19 }
20 if (value == DBNull.Value)
21 {
22 return "<DBNull>";
23 }
24 }
25 return base.ConvertTo(context, culture, value, destinationType);
26 }
27
28 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
29 {
30 if (value != null && value.GetType() == typeof(string))
31 {
32 string a = (string)value;
33 if (string.Equals(a, "<null>", StringComparison.OrdinalIgnoreCase))
34 {
35 return null;
36 }
37 if (string.Equals(a, "<DBNull>", StringComparison.OrdinalIgnoreCase))
38 {
39 return DBNull.Value;
40 }
41 }
42 return base.ConvertFrom(context, culture, value);
43 }
44}
static readonly DBNull Value
Definition DBNull.cs:8
override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)