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); }
/// <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); } }
/// <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); }
/// <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); }
/// <summary> /// Constructor /// </summary> /// <param name="asms">Assemblies</param> public BinarySerializer(params Assembly[] asms) { BinarySerializerCache.RegisterTypes(asms); }