Ejemplo n.º 1
0
        public static TemplateTerminal Create(Authentication authentication, ITypeTemplate template, string prompt)
        {
            var serviceProvider = template.Dispatcher.Invoke(() => template.Type 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);
        }
Ejemplo n.º 2
0
 private TemplateTerminal(TemplateCommandContext commandContext, string prompt)
     : base(commandContext)
 {
     this.Prompt = prompt;
 }