示例#1
0
        public MessageMeta(Type t)
        {
            this.type = t;

            if (t != null)
            {
                this.id = StringHash.Hash(t.FullName);
            }
            else
            {
                this.id = 0;
            }
        }
        /// <summary>
        /// 将消息注册
        /// </summary>
        /// <param name="id"></param>
        /// <param name="t"></param>
        public static MessageMeta Register(Type t)
        {
            if (!GetByType(t).Equals(MessageMeta.Empty))
            {
                throw new Exception("重复的消息ID");
            }

            var mi = new MessageMeta(t);

            mi.id   = StringHash.Hash(t.FullName);
            mi.type = t;

            _idmap.Add(mi.id, mi);
            _typemap.Add(t, mi);
            _namemap.Add(mi.name, mi);

            return(mi);
        }