/// <summary> /// 自定义参数 /// </summary> /// <param name="parameter"></param> /// <returns></returns> protected virtual Operand GetParameter(string parameter) { if (_dict.TryGetValue(parameter, out Operand operand)) { return(operand); } return(Operand.Error($"Parameter [{parameter}] is missing.")); }
/// <summary> /// 自定义 函数 /// </summary> /// <param name="funcName"></param> /// <param name="operands"></param> /// <returns></returns> protected virtual Operand ExecuteDiyFunction(string funcName, List <Operand> operands) { if (DiyFunction != null) { return(DiyFunction.Invoke(funcName, operands)); } return(Operand.Error($"DiyFunction [{funcName}] is missing.")); }
/// <summary> /// 创建操作数 /// </summary> /// <param name="txt"></param> /// <returns></returns> public static Operand CreateJson(string txt) { if ((txt.StartsWith("{") && txt.EndsWith("}")) || (txt.StartsWith("[") && txt.EndsWith("]"))) { try { var json = JsonMapper.ToObject(txt); return(Operand.Create(json)); } catch (Exception) { } } return(Operand.Error("string to json is error!")); }