public static ICommand Parse(string commandString, IInjector injector) { var commandParts = commandString.Split(' ').ToList(); var commandName = commandParts[0]; var args = commandParts.Skip(1).ToList(); // the arguments is after the command switch (commandName) { // Create command based on CommandName (and maybe arguments) case "exit": return(injector.GetService <ExitCommand>()); case "about": return(injector.GetService <AboutCommand>()); case "help": return(injector.GetService <HelpCommand>()); case "gen": return(injector.GetService <GenCommand>()); case "config": return(injector.GetService <ConfigCommand>()); default: return(new DeafultCommand(commandName)); } }
/// <summary> /// Gets the service object of the specified type. /// </summary> /// <returns> /// A service object of type <paramref name="serviceType" />. /// -or- /// null if there is no service object of type <paramref name="serviceType" />. /// </returns> /// <param name="serviceType"> /// An object that specifies the type of service object to get. /// </param> object IServiceProvider.GetService(Type serviceType) { return(_injector.GetService(serviceType)); }