public static ISerializer <T> GetSerializer <T>(IPatcherRegistry patcherRegistry)
        {
            if (patcherRegistry == DefaultPatcherRegistry)
            {
                return(Serializer <T> .Default);
            }

            return(new Serializer <T>(patcherRegistry));
        }
 private static IPatcher GetPatcher(Type type, IPatcherRegistry patcherRegistry)
 {
     lock (lockObj)
     {
         if (patcherCache.TryGetValue(type, out var patcher))
         {
             return(patcher);
         }
         patcher            = new ComplexPatcher(type, patcherRegistry);
         patcherCache[type] = patcher;
         return(patcher);
     }
 }
        public IPatcher CreatePatcher(Type type, IPatcherRegistry patcherRegistry)
        {
            var nodeType = type.ToNodeType();

            if (type.IsArray || type.IsGenericType)
            {
                return(new ListPatcher(type, nodeType, patcherRegistry));
            }

            if (nodeType == NodeType.Complex)
            {
                return(new ComplexPatcher(type, patcherRegistry));
            }

            return(new PrimitivePatcher(type, nodeType));
        }
示例#4
0
        public IPatcher CreatePatcher(Type type, IPatcherRegistry patcherRegistry)
        {
            if (type.IsArray || type.IsGenericType)
            {
                return(new ListPatcher(type, NodeType.Complex, patcherRegistry));
            }

            if (typeof(Vector2) == type ||
                typeof(Vector3) == type ||
                typeof(Vector4) == type ||
                typeof(Quaternion) == type)
            {
                return(new ComplexPatcher(type, patcherRegistry));
            }

            if (typeof(Vector2Int) == type || typeof(Vector3Int) == type)
            {
                return(new VectorIntPatcher(type, typeof(Vector2Int) == type ? 2 : 3));
            }

            return(new ScriptableObjectPatcher(type, patcherRegistry));
        }
 public static T Deserialize <T>(byte[] bin, IPatcherRegistry patcherRegistry, IFormatterRegistry formatterRegistry)
 => GetSerializer <T>(patcherRegistry).Deserialize(bin, formatterRegistry);
 public static byte[] Serialize <T>(T obj, IPatcherRegistry patcherRegistry, IFormatterRegistry formatterRegistry)
 => GetSerializer <T>(patcherRegistry).Serialize(obj, formatterRegistry);
示例#7
0
 public static IPatcher CreatePatcher(this IPatcherRegistry registry, Type type)
 => registry.FindFactory(type)?.CreatePatcher(type, registry);
 public ScriptableObjectPatcher(Type type, IPatcherRegistry patcherRegistry)
 {
     this.type            = type;
     this.patcherRegistry = patcherRegistry;
 }