Skip to content

Commit

Permalink
Modified TypeModel to account for 0-1 boolean definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddays committed Feb 20, 2019
1 parent 54ea71e commit 9e8c51b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,18 @@ public override CodeExpression GetDefaultValueFor(string defaultString, bool att
{
var rv = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(DateTime)), "Parse", new CodePrimitiveExpression(defaultString));
return rv;
}
}
else if (type == typeof(Boolean) && !String.IsNullOrEmpty(defaultString) && !String.IsNullOrWhiteSpace(defaultString)) {
if (defaultString == "0") {
//alternate false
return new CodePrimitiveExpression(false);
} else if (defaultString == "1") {
return new CodePrimitiveExpression(true);
} else {
return new CodePrimitiveExpression(Convert.ChangeType(defaultString, ValueType));
}
}


return new CodePrimitiveExpression(Convert.ChangeType(defaultString, ValueType));
}
Expand Down

0 comments on commit 9e8c51b

Please sign in to comment.