public void RegistePacket(ushort packetID, PacketCreator creator)
 {
     //if (!m_Buf.ContainsKey(packetID)) {
     //    m_Buf.Add(packetID, creator);
     //}
     if (m_Buf[packetID] != null) {
         throw new Exception(packetID.ToString() + " 对应的包构造器已经存在,它是:" + m_Buf[packetID].ToString());
     }
     else {
         m_Buf[packetID] = creator;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="packetId">包ID</param>
 /// <param name="creatorType">包构造器类型</param>
 /// <param name="memo">备注</param>
 public PktHandlerAttribute(ushort packetId, Type creatorType, string memo)
 {
     if (packetId <= 0) {
         throw new ArgumentException("packetId必须大于0", "packetid");
     }
     if (creatorType == null) {
         throw new ArgumentNullException("creatorType不能为空", "creatorType");
     }
     PacketID = packetId;
     Memo = memo;
     PacketCreator = Activator.CreateInstance(creatorType) as PacketCreator;
 }
 public void RegistePacket(ushort packetID, PacketCreator creator)
 {
     //if (!m_Buf.ContainsKey(packetID)) {
     //    m_Buf.Add(packetID, creator);
     //}
     if (m_Buf[packetID] != null)
     {
         throw new Exception(packetID.ToString() + " 对应的包构造器已经存在,它是:" + m_Buf[packetID].ToString());
     }
     else
     {
         m_Buf[packetID] = creator;
     }
 }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="packetId">包ID</param>
 /// <param name="creatorType">包构造器类型</param>
 /// <param name="memo">备注</param>
 public PktHandlerAttribute(ushort packetId, Type creatorType, string memo)
 {
     if (packetId <= 0)
     {
         throw new ArgumentException("packetId必须大于0", "packetid");
     }
     if (creatorType == null)
     {
         throw new ArgumentNullException("creatorType不能为空", "creatorType");
     }
     PacketID      = packetId;
     Memo          = memo;
     PacketCreator = Activator.CreateInstance(creatorType) as PacketCreator;
 }