uint GetIdByType <T>() where T : IMessage { Type t = typeof(T); if (!type2iddic.ContainsKey(t)) { MessageIDAttribute ca = t.GetCustomAttribute <MessageIDAttribute>(false); type2iddic[t] = ca.main * MAINNUM + ca.sub; } return(type2iddic[t]); }
public void Quest(IMessage data) { byte[] arr = null; if (data != null) { data.ToData(out arr); } MessageIDAttribute att = data.GetType().GetCustomAttribute <MessageIDAttribute>(false); Quest(att.main, att.sub, arr); }