コード例 #1
0
        public int CheckDigit(object o, string property)
        {
            if (o == null)
            {
                return(0);
            }
            if (property == null || property.Length <= 0)
            {
                return(0);
            }
            Type   ptype;
            int    ival = -1;
            string testvalue;

            // check to see whether this is a direct value request, or a test
            string[] argtest = BaseXmlSpawner.ParseString(property, 2, "<>!=");
            if (argtest.Length > 1)
            {
                // ok, its a test, so test it
                string status_str;
                if (BaseXmlSpawner.CheckPropertyString(null, o, property, null, out status_str))
                {
                    return(1); // true
                }
                else
                {
                    return(0); // false
                }
            }
            // otherwise get the value of the property requested
            string result = BaseXmlSpawner.GetPropertyValue(null, o, property, out ptype);

            string[] arglist = BaseXmlSpawner.ParseString(result, 2, "=");
            if (arglist.Length < 2)
            {
                return(-1);
            }
            string[] arglist2 = BaseXmlSpawner.ParseString(arglist[1], 2, " ");
            if (arglist2.Length > 0)
            {
                testvalue = arglist2[0].Trim();
            }
            else
            {
                return(-1);
            }

            if (BaseXmlSpawner.IsNumeric(ptype))
            {
                try
                {
                    ival = Convert.ToInt32(testvalue, 10);
                }
                catch
                {
                }
            }
            return(ival);
        }