public static JSONObj Create <T>(T val)
    {
        JSONObj obj = new JSONObj();

        switch (System.Type.GetTypeCode(val.GetType()))
        {
        case System.TypeCode.Byte:
        case System.TypeCode.SByte:
        case System.TypeCode.UInt16:
        case System.TypeCode.UInt32:
        case System.TypeCode.Int16:
        case System.TypeCode.Int32:
        case System.TypeCode.Int64:
            obj = JSONObj.Create(System.Convert.ToInt64(val));
            break;

        case System.TypeCode.Decimal:
        case System.TypeCode.Double:
        case System.TypeCode.Single:
            obj = JSONObj.Create(System.Convert.ToSingle(val));
            break;

        case System.TypeCode.Boolean:
            obj = JSONObj.Create(System.Convert.ToBoolean(val));
            break;

        case System.TypeCode.UInt64:
            Debug.Assert(true, "UInt64 unsupported");
            break;

        default:
            obj = JSONObj.CreateStringObject(val.ToString());
            break;
        }

        return(obj);
    }
示例#2
0
 // Nodes for comparing a column to multiple values (e.g. between)
 private QueryNode CreateComparisonNode <T>(string column, QueryOp op, T value1, T value2)
 {
     return(new QueryNode(QueryNodeType.Comparison, column, op, JSONObj.Create(value1), JSONObj.Create(value2)));
 }