Esempio n. 1
0
 /// <summary>
 /// 翻译.
 /// </summary>
 /// <param name="content"></param>
 /// <param name="modelInfo"></param>
 /// <returns></returns>
 public string Transfer(string content, EntityInfo modelinfo, Object modelObj)
 {
     content = content.TrimEnTa().TrimCVSS();
     IObjExecute execute; 
     if (content.TrimEnTa().StartsWith("if("))
     {
          execute = new JudgeExecute();
     }
     else
     {
          execute = new BaseExecute();
     }
     //return execute.Execute(modelObj, modelinfo, content) as string;
     object obb = execute.Execute(modelObj, modelinfo, content);
     string res = obb as string;
     return res;
 }
Esempio n. 2
0
        public object Execute(object obj, EntityInfo modelinfo, string pattern)
        {
            try
            {
                List<string> regex = pattern.RegBaseStrList(@"(?is)\[.*?\]");
                BaseExecute exec = new BaseExecute();
                string tmpstr = "";
                foreach (string str in regex)
                {
                    tmpstr = str.TrimStart('[').TrimEnd(']');
                    string result = exec.Execute(obj, modelinfo, tmpstr) as string;
                    pattern = pattern.Replace('[' + tmpstr + ']', result);
                }

                return pattern;
            }
            catch (Exception ex)
            {
                //如果打开检查,则返回 检查的结果,否则返回空。
                return ExCtr.Return_EX(ex, pattern);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pattern">已经被拆分出来的字符串</param>
 /// <param name="modelInfo"></param>
 /// <returns></returns>
 public string Transfer(string pattern, EntityInfo modelinfo, Object modelobj)
 {
     pattern = pattern.TrimPat().TrimEnTa();
     BaseExecute exec = new BaseExecute();
     return exec.Execute(modelobj, modelinfo, pattern) as string;
 }
Esempio n. 4
0
        public object Execute(object obj, EntityInfo modelinfo, string pattern)
        {
            try
            {
                string exAcondexB = pattern.RegBaseStr(@"(?is)if(.*?){");
                string exC = pattern.RegBaseStr(@"(?is)\)\{.*?\}else\{");
                string exD = pattern.RegBaseStr(@"(?is)\}else\{.*?\}");

                exC = exC.TrimStart("){".ToArray()).Replace("}else{", "");
                exD = exD.Replace("}else{", "").TrimEnd("}".ToArray());

                string exA, exB;
                BaseExecute exec = new BaseExecute();

                String Result = "";
                if (exAcondexB.Contains("=="))
                {
                    string[] exABS = exAcondexB.Split("==".ToCharArray());
                    exA = exABS[0].TrimEnTa();
                    exA = exA.Replace("if(", "");
                    exB = exABS[2].TrimEnTa().Replace("){", "");

                    string reA = exec.Execute(obj, modelinfo, exA) as string;
                    string reB = exec.Execute(modelinfo, modelinfo, exB) as string;
                    if (reA == reB)
                    {
                        Result = exec.Execute(obj, modelinfo, exC) as string;
                    }
                    else
                    {
                        Result = exec.Execute(obj, modelinfo, exD) as string;
                    }

                }else if (exAcondexB.Contains("!="))
                {
                    string[] exABS = exAcondexB.Split("!=".ToCharArray());
                    exA = exABS[0].TrimEnTa();
                    exA = exA.Replace("if(", "");
                    exB = exABS[2].TrimEnTa().Replace("){", "");

                    string reA = exec.Execute(obj, modelinfo, exA) as string;
                    string reB = exec.Execute(modelinfo, modelinfo, exB) as string;
                    if (reA == reB)
                    {
                        Result = exec.Execute(obj, modelinfo, exC) as string;
                    }
                    else
                    {
                        Result = exec.Execute(obj, modelinfo, exD) as string;
                    }
                }
                else
                {
                    exAcondexB = exAcondexB.Replace("if(", "");
                    exAcondexB = exAcondexB.Replace("){", "");
                    bool filter = Boolean.Parse(exec.Execute(obj, modelinfo, exAcondexB).ToString());
                    string[] exABS = exAcondexB.Split("!=".ToCharArray());
                    if (filter)
                    {
                        // 执行A.
                        Result = exec.Execute(obj, modelinfo, exC) as string;
                    }
                    else
                    {
                        // 执行B.
                        Result = exec.Execute(obj, modelinfo, exD) as string;
                    }

                }
                //else if (exAcondexB.Contains("containtable(")) {
                //    string tableName = exAcondexB.Replace("containtable(", "");
                //    tableName = tableName.TrimEnd(')');

                //    //exA = exABS[0].TrimEnTa();
                //    //exA = exA.Replace("if(", "");
                //    //string reA = exec.Execute(obj, modelinfo, exA);
                //    //Result = exec.Execute(obj, modelinfo, exC);
                //}

                return Result;
            }
            catch (Exception ex)
            {
                //如果打开检查,则返回 检查的结果,否则返回空。
                return ExCtr.Return_EX(ex, pattern);
            }

        }