private IEnumerable<CommandBinding> GetDefaultBindings(IInputProvider inputProvider, ICommand command) { if (command == null) { yield break; } var attributes = command.GetType().GetCustomAttributes(typeof(DefaultBindingAttribute), false).OfType<DefaultBindingAttribute>(); foreach (var defaultBinding in attributes.Where((attr) => attr.ProviderType == inputProvider.GetType())) { yield return new CommandBinding(defaultBinding.InputSequence, command); } }
private void IncludeDefaultBindings(ICommand command) { if (Bindings.Any((binding) => binding.Command == command)) { return; } foreach (var defaultBinding in GetDefaultBindings(InputProvider, command)) { Bindings.Add(defaultBinding); } }
private static MenuItem BuildCommandMenuItem(ICommand command) { return new MenuItem { Command = NoCapCommands.Execute, CommandParameter = command, Header = command.Name, }; }