Line data Source code
1 : using System;
2 : using System.ComponentModel;
3 : using System.Globalization;
4 :
5 : namespace Cqrs.WebApi.Formatters.FormMultipart.Infrastructure.TypeConverters
6 : {
7 : public class BooleanConverterEx : BooleanConverter
8 0 : {
9 0 : public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
10 : {
11 : if (value != null)
12 : {
13 : var str = value.ToString();
14 :
15 : if (String.Compare(str, "on", culture, CompareOptions.IgnoreCase) == 0)
16 : return true;
17 :
18 : if (String.Compare(str, "off", culture, CompareOptions.IgnoreCase) == 0)
19 : return false;
20 : }
21 :
22 : return base.ConvertFrom(context, culture, value);
23 : }
24 : }
25 : }
|