/// <summary>
        /// Adds a command without settings that executes a delegate.
        /// </summary>
        /// <param name="configurator">The configurator.</param>
        /// <param name="name">The name of the command.</param>
        /// <param name="func">The delegate to execute as part of command execution.</param>
        /// <returns>A command configurator that can be used to configure the command further.</returns>
        public static ICommandConfigurator AddDelegate(
            this IConfigurator configurator,
            string name,
            Func <CommandContext, int> func)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            return(configurator.AddDelegate <EmptyCommandSettings>(name, (c, _) => func(c)));
        }
Example #2
0
        /// <summary>
        /// Adds a command without settings that executes a delegate.
        /// </summary>
        /// <typeparam name="TSettings">The command setting type.</typeparam>
        /// <param name="configurator">The configurator.</param>
        /// <param name="name">The name of the command.</param>
        /// <param name="func">The delegate to execute as part of command execution.</param>
        /// <returns>A command configurator that can be used to configure the command further.</returns>
        public static IConfigurator <TSettings> AddDelegate <TSettings>(
            this IConfigurator <TSettings> configurator,
            string name,
            Func <CommandContext, int> func)
            where TSettings : CommandSettings
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            configurator.AddDelegate <TSettings>(name, (c, _) => func(c));
            return(configurator);
        }