public CodeFenceAnnotationsParser(
            IDefaultCodeBlockAnnotations defaultAnnotations = null,
            Action <Command> configureCsharpCommand         = null,
            Action <Command> configureFsharpCommand         = null,
            Action <Command> configureConsoleCommand        = null)
        {
            _defaultAnnotations = defaultAnnotations;

            var languageBinder =
                new Lazy <ModelBinder>(() => new ModelBinder(CodeBlockAnnotationsType));

            _modelBindersByCommand = new Dictionary <ICommand, Lazy <ModelBinder> >
            {
                [CreateCsharpCommand(configureCsharpCommand)]   = languageBinder,
                [CreateFsharpCommand(configureFsharpCommand)]   = languageBinder,
                [CreateConsoleCommand(configureConsoleCommand)] = new Lazy <ModelBinder>(() => new ModelBinder(typeof(OutputBlockAnnotations)))
            };

            _supportedLanguages = new HashSet <string>(_modelBindersByCommand.Keys.SelectMany(c => c.Aliases));

            var rootCommand = new RootCommand();

            foreach (var command in _modelBindersByCommand.Keys)
            {
                rootCommand.Add((Command)command);
            }

            _parser = new Parser(rootCommand);
        }
Esempio n. 2
0
 public CodeFenceAnnotationsParser(
     IDefaultCodeBlockAnnotations defaultAnnotations = null,
     Action <Command> configureCsharpCommand         = null)
 {
     this.defaultAnnotations = defaultAnnotations;
     _parser      = CreateOptionsParser(configureCsharpCommand);
     _modelBinder = new Lazy <ModelBinder>(CreateModelBinder);
 }
Esempio n. 3
0
 public MarkdownProject(
     IDirectoryAccessor directoryAccessor,
     PackageRegistry packageRegistry,
     IDefaultCodeBlockAnnotations defaultAnnotations = null)
 {
     DirectoryAccessor   = directoryAccessor ?? throw new ArgumentNullException(nameof(directoryAccessor));
     _packageRegistry    = packageRegistry ?? throw new ArgumentNullException(nameof(packageRegistry));
     _defaultAnnotations = defaultAnnotations;
 }
 public LocalCodeFenceAnnotationsParser(
     IDirectoryAccessor directoryAccessor,
     PackageRegistry packageRegistry,
     IDefaultCodeBlockAnnotations defaultAnnotations = null) : base(defaultAnnotations, csharp =>
 {
     AddProjectOption(csharp, directoryAccessor);
     AddSourceFileOption(csharp);
 })
 {
     _directoryAccessor = directoryAccessor;
     _packageRegistry   = packageRegistry ?? throw new ArgumentNullException(nameof(packageRegistry));
 }
 public static MarkdownPipelineBuilder UseCodeBlockAnnotations(
     this MarkdownPipelineBuilder pipeline,
     IDirectoryAccessor directoryAccessor,
     PackageRegistry packageRegistry,
     IDefaultCodeBlockAnnotations defaultAnnotations = null)
 {
     return(pipeline.UseCodeBlockAnnotations(
                new LocalCodeFenceAnnotationsParser(
                    directoryAccessor,
                    packageRegistry,
                    defaultAnnotations)));
 }
Esempio n. 6
0
        public MarkdownProcessingContext(
            IDirectoryAccessor rootDirectory,
            IDefaultCodeBlockAnnotations defaultAnnotations = null,
            WriteFile writeFile = null,
            IConsole console    = null)
        {
            RootDirectory = rootDirectory;
            Console       = console ?? new SystemConsole();

            var packageRegistry = PackageRegistry.CreateForTryMode(rootDirectory);

            Project = new MarkdownProject(
                rootDirectory,
                packageRegistry,
                defaultAnnotations ?? new DefaultCodeBlockAnnotations());

            _lazyWorkspaceServer = new Lazy <IWorkspaceServer>(() => new WorkspaceServerMultiplexer(packageRegistry));

            WriteFile = writeFile ?? File.WriteAllText;
        }