erminas.SmartAPI.Utils.XmlUtil.GetBoolAttributeValue C# (CSharp) Method

GetBoolAttributeValue() public static method

public static GetBoolAttributeValue ( this xmlElement, string attributeName ) : bool?
xmlElement this
attributeName string
return bool?
        public static bool? GetBoolAttributeValue(this XmlElement xmlElement, string attributeName)
        {
            int? value = xmlElement.GetIntAttributeValue(attributeName);
            if (value == null)
            {
                return null;
            }
            if (value == 1)
            {
                return true;
            }
            if (value == 0)
            {
                return false;
            }
            throw new SmartAPIException((ServerLogin) null,
                                        string.Format(
                                            "Could not convert value '{0}' of attribute '{1}' to a boolean value", value,
                                            attributeName));
        }