/// <summary> /// Inits the console. /// </summary> /// <param name="commandLineText">Command line text.</param> /// <param name="helpCommandString">Help command string.</param> public void InitConsole(string commandLineText, string helpCommandString) { ServiceConsoleEventHandler <ServiceEventArgs> beforeInitHandler = this.BeforeInit; if (beforeInitHandler != null) { this.BeforeInit(new EventArgs.ServiceEventArgs()); } for ( ; true;) { Console.Write(commandLineText); var entryLine = Console.ReadLine(); foreach (IServiceCommand command in this.Commands) { if (entryLine == command.Name) { command.DoEntered(); } } if (entryLine == helpCommandString) { foreach (IServiceCommand command in this.Commands) { Console.WriteLine(command.Name + " - " + command.Description); } } } }
/// <summary> /// Dos the entered. /// </summary> public void DoEntered() { ServiceConsoleEventHandler <ServiceConsoleCommandEventArgs> handler = this.OnEntered; if (handler != null) { handler(new ServiceConsoleCommandEventArgs(this)); } }