예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        /// <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);
                }
            }
        }