/// <summary> /// 预处理参数 /// </summary> /// <param name="paraters"></param> /// <returns></returns> internal static void DealRefParamList(ref IList <CParamter> paraters, IFormulaCodeParse formulaParse) { IList <CParamter> arrErrorParams = new List <CParamter>(); Regex reg = new Regex(formulaParse.RegexParamNameString); //加载HS集合 Hashtable hs = new Hashtable(); foreach (CParamter item in paraters) { if (!hs.ContainsKey(item.Key)) { hs.Add(item.Key, item); } } foreach (DictionaryEntry h in hs) { CParamter item = (CParamter)h.Value; //有公式的时候 if (item.FormulaStr != null && item.FormulaStr.Trim().Length > 0) { MatchCollection col = reg.Matches(item.FormulaStr); foreach (Match match in col) { //参数存在 if (hs.ContainsKey(match.Value)) { item.RefParams.Add((CParamter)hs[match.Value]); } else { arrErrorParams.Add((CParamter)hs[match.Value]); } } } } //缺少参数 if (arrErrorParams.Count > 0) { throw new CParamterException(arrErrorParams); } }
public void CalcaluteParamters(ref IList <CParamter> paramters) { IList <CParamter> errorArr = new List <CParamter>(); Hashtable hsParams = new Hashtable(); foreach (object item in this._Paramters) { CParamter pObj = (CParamter)item; hsParams.Add(pObj.Key, pObj); } //赋值 foreach (CParamter item in paramters) { CParamter pObj = (CParamter)item; //内部参数对象赋值 if (hsParams.ContainsKey(pObj.Key)) { item.PValue = pObj.PValue; } else { errorArr.Add(pObj); } } //有不存在的参数 if (errorArr.Count > 0) { throw new CParamterException(errorArr); } foreach (CParamter item in paramters) { CParamter param = (CParamter)hsParams[item.Key]; item.PValue = param.PValue; } }