Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 internal static bool TryGet(Type type, out CustomTypeInfo customTypeInfo)
 {
     return(typeDict.TryGetValue(type, out customTypeInfo));
 }
Exemplo n.º 3
0
 internal static bool TryGet(byte typeCode, out CustomTypeInfo customTypeInfo)
 {
     return(codeDict.TryGetValue(typeCode, out customTypeInfo));
 }