/// <summary> /// 创建此类实例 /// </summary> /// <param name="value"></param> /// <returns></returns> public static WString New(string value) { Unit context = Unit.New(null); context.VarMap.Set("argument", VarData.New(value)); context.VarMap.Set("returnvalue", VarData.New(value)); return(new WString { IsInit = true, IsRan = true, Scope = context }); }
public static WNumber New(double d) { Unit context = Unit.New(null); context.VarMap.Set("argument", VarData.New(d)); context.VarMap.Set("returnvalue", VarData.New(d)); return(new WNumber { IsInit = true, IsRan = true, Scope = context }); }
/// <summary> /// 设置当前Unit值的参数,这里将不会立即执行 /// 将会忽略Unit的Name属性 /// </summary> /// <param name="args"></param> public virtual void Set(params Unit[] args) { // 如果传入的是字符串 if (args != null && args.Length >= 1 && args[0].GetValue().Data is string) { var code = args[0].GetValue().Data as string; VarMap.Set("source", VarData.New(code)); // source 用来保存源代码以及所在的位置,这里暂时只保存源代码 IsInit = true; } else { throw new NotImplementedException("Set 函数没有实现"); } }