Exemplo n.º 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 <MessagePackObjectAttribute>();

            if (attribute != null)
            {
                var MSGID = type.FirstAttribute <MSGID>();
                if (MSGID != null)
                {
                    Regist(type, MSGID.ID,
                           MessagePackSerializerEx.MakeS(type), MessagePackSerializerEx.MakeD(type), key);
                }
            }
        }
Exemplo n.º 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 <MessagePackObjectAttribute>();

            if (attribute != null)
            {
                var MSGID = type.FirstAttribute <MSGID>();
                if (MSGID != null)
                {
                    Regist <T>(MSGID.ID,
                               MessagePackSerializerEx.Serialize, MessagePackSerializerEx.MakeD(type), key);
                }
            }
        }