示例#1
0
 /// <summary>
 /// 创建操作数
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static Operand Create(string obj)
 {
     if (object.Equals(null, obj))
     {
         return(Operand.CreateNull());
     }
     return(new OperandString(obj));
 }
示例#2
0
 /// <summary>
 /// 转Array类型
 /// </summary>
 /// <param name="errorMessage"></param>
 /// <returns></returns>
 public Operand ToArray(string errorMessage = null)
 {
     if (Type == OperandType.ARRARY)
     {
         return(this);
     }
     if (IsError)
     {
         return(this);
     }
     if (Type == OperandType.JSON)
     {
         if (JsonValue.IsArray)
         {
             List <Operand> list = new List <Operand>();
             foreach (JsonData v in JsonValue)
             {
                 if (v.IsString)
                 {
                     list.Add(Operand.Create(v.StringValue));
                 }
                 else if (v.IsBoolean)
                 {
                     list.Add(Operand.Create(v.BooleanValue));
                 }
                 else if (v.IsDouble)
                 {
                     list.Add(Operand.Create(v.NumberValue));
                 }
                 else if (v.IsNull)
                 {
                     list.Add(Operand.CreateNull());
                 }
                 else
                 {
                     list.Add(Operand.Create(v));
                 }
             }
             return(Create(list));
         }
     }
     return(Error(errorMessage));
 }
示例#3
0
 /// <summary>
 /// 添加自定义参数
 /// </summary>
 /// <param name="json"></param>
 public void AddParameterFromJson(string json)
 {
     if (json.StartsWith("{") && json.EndsWith("}"))
     {
         var jo = JsonMapper.ToObject(json);
         if (jo.IsObject)
         {
             foreach (var item in jo.inst_object)
             {
                 var v = item.Value;
                 if (v.IsString)
                 {
                     _dict[item.Key] = Operand.Create(v.StringValue);
                 }
                 else if (v.IsBoolean)
                 {
                     _dict[item.Key] = Operand.Create(v.BooleanValue);
                 }
                 else if (v.IsDouble)
                 {
                     _dict[item.Key] = Operand.Create(v.NumberValue);
                 }
                 else if (v.IsObject)
                 {
                     _dict[item.Key] = Operand.Create(v);
                 }
                 else if (v.IsArray)
                 {
                     _dict[item.Key] = Operand.Create(v);
                 }
                 else if (v.IsNull)
                 {
                     _dict[item.Key] = Operand.CreateNull();
                 }
             }
             return;
         }
     }
     throw new Exception("Parameter is not json string.");
 }