/// <summary> /// Configure the command with the <see cref="IParserOptions" /> and the <see cref="IConsole" /> of the parser. /// </summary> /// <param name="parserOptions">The <see cref="IParserOptions" />.</param> /// <param name="dependencyResolverScope">The <see cref="IDependencyResolverScope" />.</param> /// <param name="commandType">The <see cref="CommandType" /> of the command.</param> public virtual void Configure(IParserOptions parserOptions, IDependencyResolverScope dependencyResolverScope, CommandType commandType) { ParserOptions = parserOptions; CurrentDependencyResolverScope = dependencyResolverScope; CommandType = commandType; }
/// <summary> /// Create the command from its type. /// </summary> /// <param name="dependencyResolver">The scoped dependendy resolver.</param> /// <param name="parserOptions">The options of the current parser.</param> /// <returns></returns> public ICommand CreateCommand(IDependencyResolverScope dependencyResolver, IParserOptions parserOptions) { Guard.NotNull(dependencyResolver, nameof(dependencyResolver)); Guard.NotNull(parserOptions, nameof(parserOptions)); var commandActivator = dependencyResolver.ResolveDependency<ICommandActivator>(); var command = commandActivator.ActivateCommand(Type); var commandBase = command as CommandBase; commandBase?.Configure(parserOptions, dependencyResolver, this); return command; }
internal ParseContext(ButterflyStringReader input, IParserOptions options) { Input = input; Scopes = new Stack<IScope>(); LocalLinkBaseUrl = options.LocalLinkBaseUrl; LocalImageBaseUrl = options.LocalImageBaseUrl; Analyzer = options.Analyzer ?? new HtmlAnalyzer(); ModuleFactory = options.ModuleFactory ?? new DefaultModuleFactory(LocalImageBaseUrl, new NamedTypeRegistry<IButterflyModule>().LoadDefaults()); MacroFactory = options.MacroFactory ?? new ActivatorFactory<IButterflyMacro>(new NamedTypeRegistry<IButterflyMacro>().LoadDefaults()); ScopeTree = new ScopeTree(); }
/// <summary> /// Create the command from its type. /// </summary> /// <param name="dependencyResolver">The scoped dependendy resolver.</param> /// <param name="parserOptions">The options of the current parser.</param> /// <returns></returns> public ICommand CreateCommand(IDependencyResolverScope dependencyResolver, IParserOptions parserOptions) { Guard.NotNull(dependencyResolver, nameof(dependencyResolver)); Guard.NotNull(parserOptions, nameof(parserOptions)); var commandActivator = dependencyResolver.ResolveDependency <ICommandActivator>(); var command = commandActivator.ActivateCommand(Type); var commandBase = command as CommandBase; commandBase?.Configure(parserOptions, dependencyResolver, this); return(command); }
public ParserAssebly(IParserOptions options) { _options = options; }
internal Parser(IParserOptions parserOptions) { _parserOptions = parserOptions; }
private static HelpCommand GetHelpCommand(IDependencyResolverScope dependencyResolver, IParserOptions parserOptions) { var commandTypeProvider = dependencyResolver.ResolveDependency <ICommandTypeProvider>(); var helpCommandType = commandTypeProvider.GetCommandType(HelpCommand.Name); var helpCommand = helpCommandType.CreateCommand(dependencyResolver, parserOptions) as HelpCommand; return(helpCommand); }
private static void WriteGlobalHelp(IDependencyResolverScope dependencyResolver, IParserOptions parserOptions) { var helpCommand = GetHelpCommand(dependencyResolver, parserOptions); helpCommand.Execute(); }