Ejemplo n.º 1
0
        /********************************************************************************************************************/

        private DicParam StringLike(MethodCallExpression mcExpr, StringLikeEnum type)
        {
            if (mcExpr.Object == null)
            {
                return(null);
            }
            else
            {
                var objExpr     = mcExpr.Object;
                var objNodeType = mcExpr.Object.NodeType;
                if (objNodeType == ExpressionType.MemberAccess)
                {
                    var memO    = objExpr as MemberExpression;
                    var memType = objExpr.Type;
                    if (memType == typeof(string))
                    {
                        var cp      = GetKey(memO, FuncEnum.None, CompareXEnum.None);
                        var valExpr = mcExpr.Arguments[0];
                        var val     = DC.VH.ValueProcess(valExpr, cp.ValType);
                        val        = ValueInfo.LikeVI(val, type, DC);
                        DC.Option  = OptionEnum.Compare;
                        DC.Compare = CompareXEnum.Like;
                        DC.Func    = FuncEnum.None;
                        return(DC.DPH.LikeDic(cp, val));
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
 internal static ValueInfo LikeVI(ValueInfo vi, StringLikeEnum likeType, Context dc)
 {
     if (likeType == StringLikeEnum.Contains)
     {
         return(vi);
     }
     else if (likeType == StringLikeEnum.StartsWith)
     {
         return(new ValueInfo
         {
             Val = $"{vi.Val}%",
             ValStr = string.Empty
         });
     }
     else if (likeType == StringLikeEnum.EndsWith)
     {
         return(new ValueInfo
         {
             Val = $"%{vi.Val}",
             ValStr = string.Empty
         });
     }
     else
     {
         throw XConfig.EC.Exception(XConfig.EC._026, $"{likeType.ToString()}");
     }
 }
Ejemplo n.º 3
0
        /********************************************************************************************************************/

        private DicParam StringLike(MethodCallExpression mcExpr, StringLikeEnum type, string funcStr)
        {
            if (mcExpr.Object == null)
            {
                return(null);
            }
            else
            {
                var objExpr     = mcExpr.Object;
                var objNodeType = mcExpr.Object.NodeType;
                if (objNodeType == ExpressionType.MemberAccess)
                {
                    var memO    = objExpr as MemberExpression;
                    var memType = objExpr.Type;
                    if (memType == typeof(string))
                    {
                        var keyTuple = GetKey(memO, FuncEnum.None);
                        var val      = default((object val, string valStr));
                        var valExpr  = mcExpr.Arguments[0];
                        switch (type)
                        {
                        case StringLikeEnum.Contains:
                            val = DC.VH.ValueProcess(valExpr, keyTuple.valType);
                            break;

                        case StringLikeEnum.StartsWith:
                            val = ($"{DC.VH.ValueProcess(valExpr, keyTuple.valType).val}%", string.Empty);
                            break;

                        case StringLikeEnum.EndsWith:
                            val = ($"%{DC.VH.ValueProcess(valExpr, keyTuple.valType).val}", string.Empty);
                            break;
                        }
                        DC.Option  = OptionEnum.Like;
                        DC.Compare = CompareEnum.None;
                        DC.Func    = FuncEnum.None;
                        return(DC.DPH.LikeDic(keyTuple.classFullName, keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        /********************************************************************************************************************/

        private DicModel StringLike(MethodCallExpression mcExpr, StringLikeEnum type)
        {
            if (mcExpr.Object == null)
            {
                return(null);
            }
            else
            {
                var objExpr     = mcExpr.Object;
                var objNodeType = mcExpr.Object.NodeType;
                if (objNodeType == ExpressionType.MemberAccess)
                {
                    var memO    = objExpr as MemberExpression;
                    var memType = objExpr.Type;
                    if (memType == typeof(string))
                    {
                        var keyTuple = GetKey(memO, OptionEnum.Like);
                        var val      = string.Empty;
                        switch (type)
                        {
                        case StringLikeEnum.Contains:
                            val = DC.VH.GetCallVal(mcExpr);
                            break;

                        case StringLikeEnum.StartsWith:
                            val = $"{DC.VH.GetCallVal(mcExpr)}%";
                            break;

                        case StringLikeEnum.EndsWith:
                            val = $"%{DC.VH.GetCallVal(mcExpr)}";
                            break;
                        }
                        return(DicHandle.CallLikeHandle(keyTuple.key, keyTuple.alias, val, keyTuple.valType));
                    }
                }
            }

            return(null);
        }