Example #1
0
 internal Command(string name, Action commandAction, bool terminable, bool builtIn, string summary = null, string description = null,
                  CommandExecutionMode executionMode = CommandExecutionMode.Normal)
     : this(name, commandAction, summary, description, executionMode)
 {
     Terminable = terminable;
     BuiltIn    = builtIn;
 }
 public static void Describe(CommandLineInterpreterConfiguration config, IConsoleAdapter console, string applicationName, CommandExecutionMode executionMode, IOptionNameHelpAdorner adorner = null)
 {
     if (config.DefaultCommand != null && executionMode == CommandExecutionMode.CommandLine)
         AddDefaultCommandText(console, config.DefaultCommand, applicationName, adorner);
     else
         AddCommandListText(console, config, adorner, executionMode);
 }
Example #3
0
 public Command(string name, Action <string> commandAction, string summary = null, string description = null,
                CommandExecutionMode executionMode = CommandExecutionMode.Normal)
 {
     Name = name;
     parameterizedCommandAction = commandAction;
     Summary       = summary;
     Description   = description;
     ExecutionMode = executionMode;
 }
Example #4
0
 public Command(string name, Action commandAction, string summary = null, string description = null,
                CommandExecutionMode executionMode = CommandExecutionMode.Normal)
 {
     this.commandAction = commandAction;
     Summary            = summary;
     Description        = description;
     Name          = name;
     ExecutionMode = executionMode;
 }
Example #5
0
 internal CommandInvocation(Command command, string parameters, CommandExecutionMode mode, int nestingLevel,
                            CancellationTokenSource cancellationTokenSource)
 {
     Command                 = command;
     Mode                    = mode;
     NestingLevel            = nestingLevel;
     CancellationTokenSource = cancellationTokenSource;
     Parameters              = parameters;
 }
        private static bool CommandModeFilter(CommandExecutionMode executionMode, BaseCommandConfig baseCommandConfig)
        {
            if (executionMode == CommandExecutionMode.CommandLine)
                return baseCommandConfig.ValidInNonInteractiveContext;

            if (executionMode == CommandExecutionMode.Interactive)
                return baseCommandConfig.ValidInInteractiveContext;

            return false;
        }
 private static void AddCommandListText(IConsoleAdapter console, CommandLineInterpreterConfiguration config, IOptionNameHelpAdorner adorner, CommandExecutionMode executionMode)
 {
     var commands = config.Commands.Where(c => c.Name != null && CommandModeFilter(executionMode, c)).OrderBy(c => c.Name).ToList();
     if (commands.Any())
     {
         console.WriteLine("Available commands");
         console.WriteLine();
         var commandItems = commands.Select(c => new { Command = c.Name, Text = FormatShortCommandDescription(c) });
         console.FormatTable(commandItems, FormattingOptions, ColumnSeperator);
     }
 }
Example #8
0
            public TestCommand(CommandHandler handler, string name, CommandExecutionMode executionMode,
                               Action additionalAction)
            {
                Command = new Command(name, CommandAction, executionMode: executionMode);

                this.additionalAction = additionalAction;

                if (handler != null)
                {
                    handler.RunningCommandRemoved += HandlerOnRunnigCommandRemoved;
                }
            }
Example #9
0
 internal static void SetDefaultValues()
 {
     NotificationCollectionMode =
         NotificationCollectionMode.CollectionIntefaceUseNotificationValue |
         NotificationCollectionMode.OnlyOnUiThread;
     SynchronizedCollectionExecutionMode = ExecutionMode.AsynchronousOnUiThread;
     PropertyChangeExecutionMode         = ExecutionMode.AsynchronousOnUiThread;
     ViewModelObservationMode            = ObservationMode.ParentObserveChild;
     HandleTaskExceptionBusyIndicator    = true;
     CommandCanExecuteMode    = ExecutionMode.AsynchronousOnUiThread;
     CommandExecutionMode     = CommandExecutionMode.CanExecuteBeforeExecute;
     IocContainerCreationMode = IocContainerCreationMode.Mixed;
 }
Example #10
0
 public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode)
 {
     var parameter = _parameterGetter == null || command == null ? String.Empty : _parameterGetter(command);
     if (String.IsNullOrWhiteSpace(parameter))
     {
         CommandDescriber.Describe(_config, console, DefaultApplicationNameExtractor.Extract(app.GetType()), executionMode, Adorner);
     }
     else
     {
         var chosenCommand = _config.Commands.FirstOrDefault(c => String.CompareOrdinal(c.Name, parameter) == 0);
         if (chosenCommand == null)
         {
             console.WrapLine(@"The command ""{0}"" is not supported.");
         }
         else
         {
             CommandDescriber.Describe(chosenCommand, console, executionMode, Adorner);
         }
     }
 }
 /// <summary>
 /// Crée une nouvelle instance de graphics server.
 /// </summary>
 public GraphicsServer(CommandExecutionMode mode, ContentManager content)
 {
     Content = content;
     Mode    = mode;
 }
 public static void Describe(BaseCommandConfig command, IConsoleAdapter console, CommandExecutionMode executionMode, IOptionNameHelpAdorner adorner)
 {
     console.Write(FormatFullCommandDescription(command, adorner: adorner));
 }
 public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode)
 {
     try
     {
         var parameters = injector.GetParameters(_method, new[] { command });
         MethodInvoker.Invoke(_method, command, parameters);
     }
     catch (Exception e)
     {
         Toolkit.HandleException(e, command, injector);
     }
 }
 public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode)
 {
     Execute(app, command, injector);
 }
 internal static void SetDefaultValues()
 {
     NotificationCollectionMode =
         NotificationCollectionMode.CollectionIntefaceUseNotificationValue |
         NotificationCollectionMode.OnlyOnUiThread;
     SynchronizedCollectionExecutionMode = ExecutionMode.AsynchronousOnUiThread;
     PropertyChangeExecutionMode = ExecutionMode.AsynchronousOnUiThread;
     ViewModelObservationMode = ObservationMode.ParentObserveChild;
     HandleTaskExceptionBusyIndicator = true;
     CommandCanExecuteMode = ExecutionMode.AsynchronousOnUiThread;
     CommandExecutionMode = CommandExecutionMode.CanExecuteBeforeExecute;
     IocContainerCreationMode = IocContainerCreationMode.Mixed;
 }