Пример #1
0
        public static void LoadOneConfig(this ConfigComponent self, Type configType)
        {
            byte[] oneConfigBytes = self.ConfigLoader.GetOneConfigBytes(configType.FullName);

            object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);

            self.AllConfig[configType] = category;
        }
Пример #2
0
        public static void LoadOneConfig(this ConfigComponent self, Type configType)
        {
            byte[] oneConfigBytes = Game.EventSystem.Callback <string, byte[]>(CallbackType.GetOneConfigBytes, configType.FullName);

            object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);

            self.AllConfig[configType] = category;
        }
Пример #3
0
        public static object DeserializeFrom(ushort opcode, Type type, byte[] bytes, int index, int count)
        {
            if (opcode >= 20000)
            {
                return(ProtobufHelper.FromBytes(type, bytes, index, count));
            }

            return(MongoHelper.FromBson(type, bytes, index, count));
        }
Пример #4
0
        private static void LoadOneInThread(this ConfigComponent self, Type configType, Dictionary <string, byte[]> configBytes)
        {
            byte[] oneConfigBytes = configBytes[configType.Name];

            object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);

            lock (self)
            {
                self.AllConfig[configType] = category;
            }
        }
Пример #5
0
        private static void LoadOneInThread(this ConfigComponent self, Type configType, Dictionary <string, byte[]> configBytes)
        {
            byte[] oneConfigBytes = configBytes[configType.Name];
            object category       = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);

#if !SERVER
            MethodInfo methodInfo = category.GetType().GetMethod("AfterDeserialization");
            methodInfo?.Invoke(category, null);
#endif
            lock (self)
            {
                self.AllConfig[configType] = category;
            }
        }
Пример #6
0
        public static object ToActorMessage(this MemoryStream memoryStream)
        {
            ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), 8);
            Type   type   = OpcodeTypeComponent.Instance.GetType(opcode);

            if (opcode < MessageSerializeHelper.PbMaxOpcode)
            {
                return(ProtobufHelper.FromBytes(type, memoryStream.GetBuffer(), 10, (int)memoryStream.Length - 10));
            }

            if (opcode >= MessageSerializeHelper.JsonMinOpcode)
            {
                return(JsonHelper.FromJson(type, memoryStream.GetBuffer().ToStr(10, (int)(memoryStream.Length - 10))));
            }
            return(MongoHelper.FromBson(type, memoryStream.GetBuffer(), 10, (int)memoryStream.Length - 10));
        }
Пример #7
0
        public static T LoadOneConfig <T>(this ConfigComponent self, string name = "", bool cache = false) where T : ProtoObject
        {
            Type configType = typeof(T);

            if (string.IsNullOrEmpty(name))
            {
                name = configType.FullName;
            }
            byte[] oneConfigBytes = self.ConfigLoader.GetOneConfigBytes(name);

            object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);

            if (cache)
            {
                self.AllConfig[configType] = category;
            }

            return(category as T);
        }
Пример #8
0
 public object DeserializeFrom(object instance, byte[] bytes, int index, int count)
 {
     return(ProtobufHelper.FromBytes(instance, bytes, index, count));
 }
Пример #9
0
 public object DeserializeFrom(Type type, byte[] bytes, int index, int count)
 {
     return(ProtobufHelper.FromBytes(type, bytes, index, count));
 }
Пример #10
0
 public object Clone()
 {
     byte[] bytes = ProtobufHelper.ToBytes(this);
     return(ProtobufHelper.FromBytes(this.GetType(), bytes, 0, bytes.Length));
 }