示例#1
0
        public static IEtlConsoleCommand FindCommand(string commandName)
        {
            if (commandName == null)
            {
                throw new ArgumentNullException("commandName");
            }

            var command = GetCommands();
            IEtlConsoleCommand foundCommand = null;

            foreach (var handler in command)
            {
                if (IsSupportedCommandName(handler, commandName))
                {
                    if (foundCommand != null)
                    {
                        throw new InvalidOperationException(string.Format("Too many handlers for command \"{0}\" found", commandName));
                    }

                    foundCommand = handler;
                }
            }

            return(foundCommand);
        }
        public static IEtlConsoleCommand[] GetCommands()
        {
            var types = GetCommandTypes();
            var commands = new IEtlConsoleCommand[types.Length];
            for (var i = 0; i < commands.Length; i++)
            {
                var ctor = types[i].GetConstructor(Type.EmptyTypes);
                if (ctor == null)
                {
                    throw new InvalidOperationException(string.Format("{0} must have parameterless constructor", types[i].FullName));
                }

                commands[i] = (IEtlConsoleCommand)ctor.Invoke(null);
            }

            return commands;
        }
示例#3
0
        public static IEtlConsoleCommand[] GetCommands()
        {
            var types    = GetCommandTypes();
            var commands = new IEtlConsoleCommand[types.Length];

            for (var i = 0; i < commands.Length; i++)
            {
                var ctor = types[i].GetConstructor(Type.EmptyTypes);
                if (ctor == null)
                {
                    throw new InvalidOperationException(string.Format("{0} must have parameterless constructor", types[i].FullName));
                }

                commands[i] = (IEtlConsoleCommand)ctor.Invoke(null);
            }

            return(commands);
        }
示例#4
0
 private static bool IsSupportedCommandName(IEtlConsoleCommand command, string commandName)
 {
     return(string.Equals(command.CommandName, commandName, StringComparison.InvariantCultureIgnoreCase));
 }
 private static bool IsSupportedCommandName(IEtlConsoleCommand command, string commandName)
 {
     return string.Equals(command.CommandName, commandName, StringComparison.InvariantCultureIgnoreCase);
 }