Пример #1
0
        public void AddCustomCommand(IElementAdderMenuCommand <TContext> command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            _customCommands.Add(command);
        }
Пример #2
0
        /// <summary>
        /// Gets an array of <see cref="IElementAdderMenuCommand{TContext}"/> instances
        /// that are associated with the specified <paramref name="contractType"/>.
        /// </summary>
        /// <typeparam name="TContext">Type of the context object that elements can be added to.</typeparam>
        /// <param name="contractType">Contract type of addable elements.</param>
        /// <returns>
        /// An array containing zero or more <see cref="IElementAdderMenuCommand{TContext}"/> instances.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="contractType"/> is <c>null</c>.
        /// </exception>
        /// <seealso cref="GetMenuCommandTypes{TContext}(Type)"/>
        public static IElementAdderMenuCommand <TContext>[] GetMenuCommands <TContext>(Type contractType)
        {
            var commandTypes = GetMenuCommandTypes <TContext>(contractType);
            var commands     = new IElementAdderMenuCommand <TContext> [commandTypes.Length];

            for (int i = 0; i < commandTypes.Length; ++i)
            {
                commands[i] = (IElementAdderMenuCommand <TContext>)Activator.CreateInstance(commandTypes[i]);
            }
            return(commands);
        }