Object ParseBoolean(
XmlNode node,
Type ValueType,
ParseStack parseStack,
MappingAction mappingAction)
{
if (ValueType != null && ValueType != typeof(Object)
&& ValueType != typeof(System.Boolean)
#if !FX1_0
&& ValueType != typeof(bool?)
#endif
&& ValueType != typeof(XmlRpcBoolean))
{
throw new XmlRpcTypeMismatchException(parseStack.ParseType
+ " contains boolean value where "
+ XmlRpcServiceInfo.GetXmlRpcTypeString(ValueType)
+ " expected " + StackDump(parseStack));
}
bool retVal;
parseStack.Push("boolean");
try
{
string s = node.FirstChild.Value;
if (s == "1")
{
retVal = true;
}
else if (s == "0")
{
retVal = false;
}
else
{
throw new XmlRpcInvalidXmlRpcException(
"reponse contains invalid boolean value "
+ StackDump(parseStack));
}
}
finally
{
parseStack.Pop();
}
if (ValueType == typeof(XmlRpcBoolean))
return new XmlRpcBoolean(retVal);
else
return retVal;
}