Пример #1
0
        public static ConsoleInterfaceBuilder AddSyntaxHighlighting(
            this ConsoleInterfaceBuilder builder,
            Action <CommandLineHighlightingOptions> options = null)
        {
            var services = builder.Services;

            services.AddSingleton <ITextHighlighter <TextStyle>, CommandLineSyntaxHighlighter>();
            services.AddSingleton <ILineViewProvider, ConsoleHighlightedLineViewProvider>();

            var parserService = services.FirstOrDefault(_ => _.ServiceType == typeof(ICommandLineParser));

            if (parserService == null)
            {
                services.AddSingleton <ICommandLineParser, CommandLineParser>();
                services.AddSingleton <ICommandLineLexer, CommandLineLexer>();
                services.AddSingleton <ISemanticModel, EmptySemanticModel>();
                services.AddSingleton <SyntaxFactory, SyntaxFactory>();
            }

            if (options != null)
            {
                services.Configure(options);
            }

            return(builder);
        }
 public static ConsoleInterfaceBuilder AddPromptMessage(
     this ConsoleInterfaceBuilder builder, Action <PromptMessageOptions> options = null)
 {
     builder.Services.AddTransient <IPromptMessage, PromptMessage>();
     if (options != null)
     {
         builder.Services.Configure(options);
     }
     return(builder);
 }
Пример #3
0
        public static CommandsHistoryBuilder AddCommandsHistory(
            this ConsoleInterfaceBuilder builder, Action <CommandsHistoryOptions> options = null)
        {
            var services = builder.Services;

            services.AddTransient <IInputHandler, CommandsHistoryInputHandler>();
            services.AddSingleton <ICommandsHistoryManager, CommandsHistoryManager>();
            if (options != null)
            {
                services.Configure(options);
            }
            return(new CommandsHistoryBuilder(services));
        }
Пример #4
0
        public static ConsoleInterfaceBuilder AddUndoRedo(
            this ConsoleInterfaceBuilder builer, Action <UndoRedoOptions> options = null)
        {
            var services = builer.Services;

            services.AddTransient <IInputHandler, UndoRedoInputHandler>();
            services.AddSingleton <IUndoRedoManager, UndoRedoManager>();

            if (options != null)
            {
                services.Configure(options);
            }

            return(builer);
        }
 public static ConsoleInterfaceBuilder AddPromptMessage(
     this ConsoleInterfaceBuilder builder, string message)
 {
     return(builder.AddPromptMessage(options => options.Message = message));
 }