Exemple #1
0
        public static TemplateTerminal Create(Authentication authentication, ITableTemplate template, string prompt)
        {
            var serviceProvider = template.Dispatcher.Invoke(() => template.Table as IServiceProvider);
            var commands        = (serviceProvider.GetService(typeof(IEnumerable <ITemplateCommand>)) as IEnumerable <ITemplateCommand>);

            var commandContext = new TemplateCommandContext(authentication, template, commands);
            var terminal       = new TemplateTerminal(commandContext, prompt)
            {
                Postfix = "$ "
            };

            foreach (var item in commands)
            {
                if (item is SaveCommand saveCommand)
                {
                    saveCommand.CloseAction = () => terminal.Cancel();
                }
                else if (item is CancelCommand cancelCommand)
                {
                    cancelCommand.CloseAction = () => terminal.Cancel();
                }
            }

            return(terminal);
        }
Exemple #2
0
 private TemplateTerminal(TemplateCommandContext commandContext, string prompt)
     : base(commandContext)
 {
     this.Prompt = prompt;
 }