示例#1
0
        //解析字符串,返回一个IToyzDateTimeObjcet接口的对象
        public static IToyzObjcet ParseToyz(string regexp)
        {
            IToyzObjcet toyz = null;

            if (string.IsNullOrEmpty(regexp))
            {
                return(toyz);
            }

            //判断查询前序
            if (regexp.StartsWith("between@"))
            {
                string   query     = regexp.Split('@')[1]; //找出查询条件
                string[] subQuerys = query.Split(',');     //拆分查询条件,获取参数数组
                if (subQuerys.Length == 2)
                {
                    string subQuery0 = subQuerys[0];
                    string subQuery1 = subQuerys[1];
                    if (ObjectUtil.IsNumberQuery(subQuery0) && ObjectUtil.IsNumberQuery(subQuery1))
                    {
                        int min = int.Parse(subQuery0.Trim('(', ')'));
                        int max = int.Parse(subQuery1.Trim('(', ')'));
                        toyz = new ToyzNumberRangeObject(min, max);
                    }
                }
            }
            else if (regexp.StartsWith("gt@") || regexp.StartsWith("lt@"))
            {
                string   query     = regexp.Split('@')[1]; //找出查询条件
                string[] subQuerys = query.Split(',');     //拆分查询条件,获取参数数组
                if (subQuerys.Length == 1)
                {
                    string subQuery0 = subQuerys[0];
                    //string subQuery1 = subQuerys[1];
                    if (ObjectUtil.IsNumberQuery(subQuery0))
                    {
                        int min = regexp.StartsWith("lt@")?int.MinValue:int.Parse(subQuery0.Trim('(', ')'));
                        int max = regexp.StartsWith("gt@") ? int.MaxValue:int.Parse(subQuery0.Trim('(', ')'));
                        toyz = new ToyzNumberRangeObject(min, max);
                    }
                }
            }


            return(toyz);
        }
示例#2
0
        //解析字符串,返回一个IToyzDateTimeObjcet接口的对象
        public static IToyzObjcet ParseToyz(string regexp)
        {
            IToyzObjcet toyz = null;
            if(string.IsNullOrEmpty(regexp))return toyz;

            //判断查询前序
            if (regexp.StartsWith("between@"))
            {

                string query = regexp.Split('@')[1];    //找出查询条件
                string[] subQuerys = query.Split(',');   //拆分查询条件,获取参数数组
                if (subQuerys.Length == 2)
                {
                    string subQuery0 = subQuerys[0];
                    string subQuery1 = subQuerys[1];
                    if (ObjectUtil.IsNumberQuery(subQuery0) && ObjectUtil.IsNumberQuery(subQuery1))
                    {
                        int min = int.Parse(subQuery0.Trim('(', ')'));
                        int max = int.Parse(subQuery1.Trim('(', ')'));
                        toyz = new ToyzNumberRangeObject(min, max);
                    }
                }
            }
            else if (regexp.StartsWith("gt@") || regexp.StartsWith("lt@"))
            {
                string query = regexp.Split('@')[1];    //找出查询条件
                string[] subQuerys = query.Split(',');   //拆分查询条件,获取参数数组
                if (subQuerys.Length ==1)
                {
                    string subQuery0 = subQuerys[0];
                    //string subQuery1 = subQuerys[1];
                    if (ObjectUtil.IsNumberQuery(subQuery0))
                    {
                        int min = regexp.StartsWith("lt@")?int.MinValue:int.Parse(subQuery0.Trim('(', ')'));
                        int max = regexp.StartsWith("gt@") ? int.MaxValue:int.Parse(subQuery0.Trim('(', ')'));
                        toyz = new ToyzNumberRangeObject(min, max);
                    }
                }
            }

            return toyz;
        }