示例#1
0
        public static bool AsBool(this string v, XObject xmlObject = null)
        {
            v = v?.Trim();
            if (String.IsNullOrEmpty(v))
            {
                return(false);
            }

            bool ret;

            if (!Boolean.TryParse(v, out ret))
            {
                Logger.Warning($"Value '{v}' cannot be parsed as boolean ({xmlObject.GetLineInfo ()})");
                return(false);
            }

            return(ret);
        }