public IEnumerable <IShortcutEntryDiscoveryInfo> GetDefinedShortcuts()
        {
            var entries          = new List <IShortcutEntryDiscoveryInfo>();
            var names            = new List <string>();
            var defaultShortcuts = new List <string>();

            Menu.GetMenuItemDefaultShortcuts(names, defaultShortcuts);
            entries.Capacity += names.Count;

            for (var index = 0; index < names.Count; ++index)
            {
                var            keys = new List <KeyCombination>();
                KeyCombination keyCombination;
                if (KeyCombination.TryParseMenuItemBindingString(defaultShortcuts[index], out keyCombination))
                {
                    keys.Add(keyCombination);
                }
                entries.Add(new MenuItemEntryDiscoveryInfo(names[index], keys));
            }

            return(entries);
        }
        public override ShortcutEntry CreateShortcutEntry(MethodInfo methodInfo)
        {
            var identifier = new Identifier(methodInfo, this);

            IEnumerable <KeyCombination> defaultCombination;

            KeyCombination keyCombination;

            if (KeyCombination.TryParseMenuItemBindingString(defaultKeyCombination, out keyCombination))
            {
                defaultCombination = new[] { keyCombination }
            }
            ;
            else
            {
                defaultCombination = Enumerable.Empty <KeyCombination>();
            }


            var type         = this is ClutchShortcutAttribute ? ShortcutType.Clutch : ShortcutType.Action;
            var methodParams = methodInfo.GetParameters();
            Action <ShortcutArguments> action;

            // We instantiate this as the specific delegate type in advance,
            // because passing ShortcutArguments in object[] via MethodInfo.Invoke() causes boxing/allocation
            if (methodParams.Any())
            {
                action = (Action <ShortcutArguments>)methodInfo.CreateDelegate(typeof(Action <ShortcutArguments>), null);
            }
            else
            {
                m_NoArgumentsAction = (Action)methodInfo.CreateDelegate(typeof(Action), null);
                action = NoArgumentShortcutMethodProxy;
            }

            return(new ShortcutEntry(identifier, defaultCombination, action, context, type));
        }