public int GetMsgId(Message message) { var index = Types.IndexOf(message.GetType()); if (index == -1) { throw new Exception("Not registered"); } return index; }