Beispiel #1
0
        public int?OnOptionsParsed(Parser parser)
        {
            if (commandObject is ICommandObject commandObjectInterface)
            {
                var exitCode = commandObjectInterface.OnOptionsParsed(parser);
                if (exitCode != null)
                {
                    return(exitCode);
                }
            }

            return(CommandProviders.Select(_ => _.OnOptionsParsed(parser))
                   .FirstOrDefault(_ => _ != null));
        }
        /// <summary>
        /// Gets the command provider of the given type.
        /// </summary>
        /// <returns>The command provider of the specified type, or <c>null</c> if not found.</returns>
        /// <typeparam name="T">The type of the command provider to get.</typeparam>
        public T GetCommandProvider <T>() where T : ICommandProvider
        {
            var commandProvider = CommandProviders.Select(c => c.Value).OfType <T>().FirstOrDefault();

            return(commandProvider);
        }