本帖最后由 卖板的 于 2022-6-14 08:58 编辑
下面红色代码位置, string result ="123456";
能正常返回值
我通过 JsHelper js = new JsHelper();
string result = js.EvalMethod(JsD, Ff, Cc);
这个在活字格插件里面返回的是错误Object reference not set to an instance of an object.
请教大神我要怎么改,
namespace HuoZiGe
{
[Icon("pack://application:,,,/MyServerCommand;component/Resources/Icon.png")]
public class MyServerCommand : Command, ICommandExecutableInServerSide, IServerCommandParamGenerator
{
[DisplayName("JS代码")]
[FormulaProperty(true)]
public object JsDaiMa { get; set; }
[DisplayName("方法名称")]
[FormulaProperty(true)]
public object FangFa { get; set; }
[DisplayName("参数字符串,号隔开")]
[FormulaProperty(true)]
public object CanShu { get; set; }
[DisplayName("返回值接收变量名")]
[FormulaProperty(true)]
public string NewParameter { get; set; }
public object newValue { get; private set; }
[Obsolete]
public ExecuteResult Execute(IServerCommandExecuteContext dataContext)
{
//Do some thing
string JsD = dataContext.EvaluateFormula(this.JsDaiMa).ToString();
string Ff = dataContext.EvaluateFormula(this.FangFa).ToString();
string Cc = dataContext.EvaluateFormula(this.CanShu).ToString();
// string Jg = dataContext.EvaluateFormula(this.FanHui).ToString();
JsHelper js = new JsHelper();
string result = js.EvalMethod(JsD, Ff, Cc);
dataContext.Parameters[NewParameter] = result ;
return new ExecuteResult();
}
public IEnumerable<GenerateParam> GetGenerateParams()
{
yield return new GenerateNormalParam()
{
ParamName = NewParameter,
};
}
}
}
|