object convertFromMsgPackObject(MsgPack.MessagePackObject mpobj) { if (mpobj.IsDictionary) { return(convertFromMsgPackObjectDictionary(mpobj.AsDictionary())); } if (mpobj.IsList) { return(convertFromMsgPackObjectList(mpobj.AsList())); } return(mpobj.ToObject()); }
/// <summary> /// 通过网络传输的object数组,会被转换成MessagePackObject, /// 这里进行数组转换 /// </summary> /// <param name="arr"></param> /// <returns></returns> public static object[] ConvertMsgPackObjectArray(object[] arr) { var arguments = new object[arr.Length]; for (var i = 0; i < arguments.Length; i++) // MsgPack.MessagePackObject arg in requestProto.Arguments) { if (arr[i] is MsgPack.MessagePackObject) { MsgPack.MessagePackObject arg = (MsgPack.MessagePackObject)arr[i]; arguments[i] = arg.ToObject(); } else { arguments[i] = arr[i]; } } return(arguments); }
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); }
public object ToObject() { return(_msgPackObject.ToObject()); }