File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Source/Shared/Models/Collections Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -32,15 +32,26 @@ public bool GetBoolean(string name) {
32
32
}
33
33
34
34
public bool GetBoolean ( string name , bool @default ) {
35
- bool value ;
36
35
string temp = null ;
37
-
38
- bool result = name != null && TryGetValue ( name , out temp ) ;
39
- if ( ! result )
36
+ if ( String . IsNullOrWhiteSpace ( name ) || ! TryGetValue ( name , out temp ) )
37
+ return @default ;
38
+
39
+ if ( String . IsNullOrEmpty ( temp ) )
40
40
return @default ;
41
41
42
- result = bool . TryParse ( temp , out value ) ;
43
- return result ? value : @default ;
42
+ temp = temp . ToLowerInvariant ( ) . Trim ( ) ;
43
+
44
+ bool value ;
45
+ if ( bool . TryParse ( temp , out value ) )
46
+ return value ;
47
+
48
+ if ( String . Equals ( temp , "yes" ) || String . Equals ( temp , "1" ) )
49
+ return true ;
50
+
51
+ if ( String . Equals ( temp , "no" ) || String . Equals ( temp , "0" ) )
52
+ return false ;
53
+
54
+ return @default ;
44
55
}
45
56
46
57
public int GetInt32 ( string name ) {
You can’t perform that action at this time.
0 commit comments