Exemplo n.º 1
0
        public DxArrayValue NewArray(string keyName)
        {
            if (keyName == "")
            {
                return(null);
            }
            DxBaseValue value  = null;
            bool        haskey = records.TryGetValue(keyName, out value);

            if (haskey)
            {
                if (value.Type == ValueType.VT_Array)
                {
                    ((DxArrayValue)value).Clear();
                    return((DxArrayValue)value);
                }
                else if (value.Type == ValueType.VT_Map)
                {
                    ((DxRecordValue)value).Clear();
                }
            }
            DxArrayValue result = new DxArrayValue();

            result.Parent = this;
            if (haskey)
            {
                records[keyName] = result;
            }
            else
            {
                records.Add(keyName, result);
            }
            return(result);
        }
Exemplo n.º 2
0
    void btnEncodeClick()
    {
        DxValue.DxRecordValue v = new DxValue.DxRecordValue();
        v.SetString("Name", "不得闲");
        v.SetInt("Age", 23);
        v.SetDouble("money", 234234234.234);
        v.SetDateTime("Date", System.DateTime.Now);
        DxValue.DxArrayValue arr = v.ForcePathArray("test.data");
        arr.SetString(-1, "gas"); //-1就是表示在末尾加
        arr.SetString(1, "234");
        arr.SetDateTime(4, System.DateTime.Now);
        Debug.Log(v.AsString);

        byte[] bt = v.AsMsgPackBytes;

        DxValue.DxRecordValue newValue = new DxValue.DxRecordValue();
        newValue.AsMsgPackBytes = bt;
        Debug.Log(newValue.AsString);


        DxValue.DxArrayValue arr1 = newValue.ArrayByPath("test.data");
        if (arr1 != null)
        {
            Debug.Log(arr1.AsString);

            byte[] arrybt = arr1.AsMsgPackBytes;

            arr1.Clear();
            Debug.Log(arr1.AsString);

            arr1.AsMsgPackBytes = arrybt;
            Debug.Log(arr1.AsString);
        }
    }
Exemplo n.º 3
0
 private void btnArrayClick()
 {
     DxValue.DxArrayValue arr = new DxValue.DxArrayValue();
     for (int i = 0; i < 5; i++)
     {
         arr.SetString(-1, "asdf");
     }
     Debug.Log(arr.AsString);
 }
Exemplo n.º 4
0
        public DxArrayValue NewArray(int idx)
        {
            idx = ifNilInitArr2idx(idx);
            DxBaseValue v = arrayList[idx];

            if (v != null)
            {
                switch (v.Type)
                {
                case ValueType.VT_Map:
                    ((DxRecordValue)v).Clear();
                    break;

                case ValueType.VT_Array:
                    return((DxArrayValue)v);
                }
            }
            DxArrayValue result = new DxArrayValue();

            result.parent  = this;
            arrayList[idx] = result;
            return(result);
        }
Exemplo n.º 5
0
    private void btnMapClick()
    {
        DxValue.DxRecordValue mapValue = new DxValue.DxRecordValue();
        mapValue.SetInt("code", 0);
        mapValue.SetString("msg", "消息返回成功");
        DxValue.DxArrayValue arr = mapValue.ForcePathArray("Data.Records");
        for (int i = 0; i < 4; i++)
        {
            DxValue.DxRecordValue rec = arr.NewRecord(-1);
            rec.SetString("Name", "不得闲" + i);
            rec.SetInt("Age", 35);
            rec.SetString("sex", "男");
            rec.SetDateTime("Birth", System.DateTime.Now);
            rec.SetDouble("Money", 2224495.9323);
            rec.SetString("mobile", "13129903278");
        }
        DxValue.DxRecordValue datamap = (DxValue.DxRecordValue)mapValue["Data"];
        datamap.SetString("msg", "人物信息表");
        Debug.Log(mapValue.AsString);

        Debug.Log(mapValue.GetInt("code", -1));
        arr = (DxValue.DxArrayValue)mapValue.ValueByPath("Data.Records");
        Debug.Log(((DxValue.DxRecordValue)arr[0]).GetString("Name", "test"));
    }