public MessagePackObjectDictionary AsDictionary()
        {
            var internalDict = _msgPackObject.AsDictionary();
            var dict         = new MessagePackObjectDictionary(internalDict.Count);

            foreach (var keyValuePair in internalDict)
            {
                dict.Add(new MessagePackObject(keyValuePair.Key), new MessagePackObject(keyValuePair.Value));
            }
            return(dict);
        }
 object convertFromMsgPackObject(MsgPack.MessagePackObject mpobj)
 {
     if (mpobj.IsDictionary)
     {
         return(convertFromMsgPackObjectDictionary(mpobj.AsDictionary()));
     }
     if (mpobj.IsList)
     {
         return(convertFromMsgPackObjectList(mpobj.AsList()));
     }
     return(mpobj.ToObject());
 }
Exemple #3
0
        static object convertFromMsgPackObject(MsgPack.MessagePackObject mpobj)
        {
            if (mpobj.IsDictionary)
            {
                return(convertFromMsgPackObjectDictionary(mpobj.AsDictionary()));
            }
            if (mpobj.IsList)
            {
                return(convertFromMsgPackObjectList(mpobj.AsList()));
            }

            object obj = mpobj.ToObject();

            if (typeof(int).IsInstanceOfType(obj))
            {
                return((Int64)(int)obj);
            }
            else if (typeof(byte).IsInstanceOfType(obj))
            {
                return((Int64)(byte)obj);
            }
            else if (typeof(short).IsInstanceOfType(obj))
            {
                return((Int64)(short)obj);
            }
            else if (typeof(ushort).IsInstanceOfType(obj))
            {
                return((Int64)(ushort)obj);
            }
            else if (typeof(char).IsInstanceOfType(obj))
            {
                return((Int64)(char)obj);
            }
            else if (typeof(uint).IsInstanceOfType(obj))
            {
                return((Int64)(uint)obj);
            }
            else if (typeof(ulong).IsInstanceOfType(obj))
            {
                return((Int64)(ulong)obj);
            }
            return(obj);
        }