Ejemplo n.º 1
0
        private static object UserFunctionImpl(string funcName, ParamObjectCollection arrParams, object callerContext)
        {
            object result = null;

            switch (funcName.ToLower())
            {
            case "power":
                result = Math.Pow(Decimal.ToDouble((decimal)arrParams[0].Value),
                                  Decimal.ToDouble((decimal)arrParams[1].Value));
                break;

            case "expparse":
                result = ExpressionParser.Parse((string)arrParams[0].Value).Identifiers.ToString();
                break;

            case "author":
                result = "Shen Zheng";
                break;

            default:
                if (BuiltInFunctionsCalculator.Instance.IsFunction(funcName))
                {
                    result = BuiltInFunctionHelper.ExecuteFunction(funcName, BuiltInFunctionsCalculator.Instance, arrParams, callerContext);
                }
                else
                {
                    throw new ApplicationException(string.Format("'{0}'是一个无法识别的标识符.", funcName));
                }
                break;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public object CalculateUserFunction(string funcName, ParamObjectCollection arrParams, object callerContext)
        {
            object result = null;

            if (this.IsFunction(funcName))
            {
                result = BuiltInFunctionHelper.ExecuteFunction(funcName, this, arrParams, callerContext);
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算内置函数
        /// </summary>
        /// <param name="funcName"></param>
        /// <param name="arrParams"></param>
        /// <param name="callerContext"></param>
        /// <returns></returns>
        public object Calculate(string funcName, ParamObjectCollection arrParams, object callerContext)
        {
            object result = null;

            if (WfCreateActivityBuiltInFunctions.Instance.IsFunction(funcName) == false)
            {
                result = MatchedActivityKey(funcName, (WfCreateActivityFunctionContext)callerContext);

                if (result == null || (string)result == string.Empty)
                {
                    throw new InvalidOperationException(string.Format("\"{0}\"是非法的函数名称", funcName));
                }
            }
            else
            {
                result = BuiltInFunctionHelper.ExecuteFunction(funcName, this, arrParams, callerContext);
            }

            return(result);
        }
 /// <summary>
 /// 计算内置函数
 /// </summary>
 /// <param name="funcName"></param>
 /// <param name="arrParams"></param>
 /// <param name="callerContext"></param>
 /// <returns></returns>
 public object Calculate(string funcName, ParamObjectCollection arrParams, object callerContext)
 {
     return(BuiltInFunctionHelper.ExecuteFunction(funcName, this, arrParams, callerContext));
 }