protected virtual void RegisterForCommands() { var type = GetType(); var attributes = type.GetCustomAttributes(typeof(RecievesCommandAttribute), true).Cast <RecievesCommandAttribute>(); foreach (var attr in attributes) { commands.RegisterCommandReceiver(attr.CommandCode, this); } }