Пример #1
0
        static bool TryRecursive(Type btype, out delReadValue readValue, out delWriteValue writeValue)
        {
            BinarySerializerCache cache = BinarySerializer.InternalCacheTypesOf(btype);

            if (cache == null)
            {
                readValue  = null;
                writeValue = null;
                return(false);
            }

            RecursiveType r = new RecursiveType(btype);

            readValue  = r.GetRecursiveValue;
            writeValue = r.SetRecursiveValue;
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Cache type
        /// </summary>
        /// <param name="type">Type</param>
        internal static BinarySerializerCache InternalCacheTypesOf(Type type)
        {
            lock (Cache)
            {
                if (Cache.TryGetValue(type, out var cache))
                {
                    return(cache);
                }

                var b = new BinarySerializerCache(type);
                if (b.Count <= 0)
                {
                    return(null);
                }

                Cache.Add(b.Type, b);
                return(b);
            }
        }
Пример #3
0
 /// <summary>
 /// Register types (call me if you load a new plugin or module)
 /// </summary>
 /// <param name="types">Types</param>
 public static void RegisterTypes(params Type[] types)
 {
     BinarySerializerCache.RegisterTypes(types);
 }
Пример #4
0
 /// <summary>
 /// Register types (call me if you load a new plugin or module)
 /// </summary>
 /// <param name="asms">Assemblies</param>
 public static void RegisterTypes(params Assembly[] asms)
 {
     BinarySerializerCache.RegisterTypes(asms);
 }
Пример #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="asms">Assemblies</param>
 public BinarySerializer(params Assembly[] asms)
 {
     BinarySerializerCache.RegisterTypes(asms);
 }