/// <summary> /// 注册程序集中所有议类 /// </summary> /// <param name="assembly"></param> /// <param name="key"></param> public static void Regist(Assembly assembly, KeyAlreadyHave key = KeyAlreadyHave.Skip) { var types = assembly.GetTypes(); foreach (var item in types) { Regist(item, key); } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="key"></param> public static void Regist <T>(KeyAlreadyHave key = KeyAlreadyHave.Skip) where T : IMessage <T> { var type = typeof(T); var MSGID = type.FirstAttribute <MSGID>(); if (MSGID != null) { Regist <T>(MSGID.ID, ProtobufLUTSerializerEx.Serialize, ProtobufLUTSerializerEx.MakeD(type), key); } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="type"></param> /// <param name="key"></param> protected internal static void Regist(Type type, KeyAlreadyHave key = KeyAlreadyHave.Skip) { if (type.IsSubclassOf(typeof(IMessage <>))) { var MSGID = type.FirstAttribute <MSGID>(); if (MSGID != null) { Regist(type, MSGID.ID, ProtobufLUTSerializerEx.MakeS(type), ProtobufLUTSerializerEx.MakeD(type), key); } } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="type"></param> /// <param name="key"></param> protected internal static void Regist(Type type, KeyAlreadyHave key = KeyAlreadyHave.Skip) { var attribute = type.FirstAttribute <ProtoContractAttribute>(); if (attribute != null) { var MSGID = type.FirstAttribute <MessageIdAttribute>(); if (MSGID != null) { Regist(type, MSGID.ID, Protobuf_netSerializerEx.MakeS(type), Protobuf_netSerializerEx.MakeD(type), key); } } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="type"></param> /// <param name="key"></param> protected internal static void Regist(Type type, KeyAlreadyHave key = KeyAlreadyHave.Skip) { var attribute = type.FirstAttribute <MessagePackObjectAttribute>(); if (attribute != null) { var MSGID = type.FirstAttribute <MSGID>(); if (MSGID != null) { Regist(type, MSGID.ID, MessagePackSerializerEx.MakeS(type), MessagePackSerializerEx.MakeD(type), key); } } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="key"></param> public static void Regist <T>(KeyAlreadyHave key = KeyAlreadyHave.Skip) { var type = typeof(T); var attribute = type.FirstAttribute <MessagePackObjectAttribute>(); if (attribute != null) { var MSGID = type.FirstAttribute <MSGID>(); if (MSGID != null) { Regist <T>(MSGID.ID, MessagePackSerializerEx.Serialize, MessagePackSerializerEx.MakeD(type), key); } } }
/// <summary> /// 注册消息类型 /// </summary> /// <param name="key"></param> public static void Regist <T>(KeyAlreadyHave key = KeyAlreadyHave.Skip) { var type = typeof(T); var attribute = type.FirstAttribute <ProtoContractAttribute>(); if (attribute != null) { var MSGID = type.FirstAttribute <MessageIdAttribute>(); if (MSGID != null) { Regist <T>(MSGID.ID, Protobuf_netSerializerEx.Serialize, Protobuf_netSerializerEx.MakeD(type), key); } } }