internal static bool TryRegisterType(Type type, byte typeCode, Func <object, byte[]> serializeFunction, Func <byte[], object> deserializeFunction)
        {
            if (codeDict.ContainsKey(typeCode) || typeDict.ContainsKey(type))
            {
                return(false);
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (serializeFunction == null)
            {
                throw new ArgumentNullException("serializeFunction");
            }
            if (deserializeFunction == null)
            {
                throw new ArgumentNullException("deserializeFunction");
            }
            CustomTypeInfo info = new CustomTypeInfo(type, typeCode, serializeFunction, deserializeFunction);

            codeDict.Add(typeCode, info);
            typeDict.Add(type, info);
            return(true);
        }
 internal static bool TryGet(Type type, out CustomTypeInfo customTypeInfo)
 {
     return(typeDict.TryGetValue(type, out customTypeInfo));
 }
 internal static bool TryGet(byte typeCode, out CustomTypeInfo customTypeInfo)
 {
     return(codeDict.TryGetValue(typeCode, out customTypeInfo));
 }