Пример #1
0
        /// <summary> 序列化(对象转字节数组) | Serialize(Convert object to bytes) </summary>
        /// <param name="typeName">自定义类型名称 | Custom type name</param>
        /// <param name="obj">对象(LBObject)</param>
        public static byte[] Serialize(string typeName, LBObject obj)
        {
            LBType customType;

            if (!LBConfig.TryGetCustomType(typeName, out customType))
            {
                throw new Exception("CustomType is null. Type name:" + typeName);
            }
            return(LBConverter.ToBytes(customType, obj));
        }
Пример #2
0
 public void SetObject(string key, LBObject value)
 {
     if (value == null)
     {
         return;
     }
     if (objectDict == null)
     {
         objectDict = new Dictionary <string, LBObject>();
     }
     if (!objectDict.ContainsKey(key))
     {
         objectDict.Add(key, value);
     }
     else
     {
         objectDict[key] = value;
     }
 }