예제 #1
0
        public static TemplateTerminal Create(Authentication authentication, ITableTemplate template, string prompt)
        {
            var serviceProvider = template.Dispatcher.Invoke(() => template.Target 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);

            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);
        }
예제 #2
0
 private TemplateTerminal(TemplateCommandContext commandContext, string prompt)
     : base(commandContext)
 {
     this.Prompt = prompt;
 }