// 收集所有网络协议的类型 private void CollectTypes() { List <Type> types = ILRManager.Instance.HotfixAssemblyTypes; for (int i = 0; i < types.Count; i++) { System.Type type = types[i]; // 判断属性标签 if (Attribute.IsDefined(type, typeof(NetworkMessageAttribute))) { // 判断是否重复 NetworkMessageAttribute attribute = HotfixTypeHelper.GetAttribute <NetworkMessageAttribute>(type); if (_types.ContainsKey(attribute.MsgID)) { throw new Exception($"Message {type} has same value : {attribute.MsgID}"); } // 添加到集合 _types.Add(attribute.MsgID, type); } } }
private static string GetMessageTypeName(Type type) { NetworkMessageAttribute attribute = GetNetworkMessageAttribute(type); return(attribute?.name ?? type.ToString()); }