Esempio n. 1
0
 /// <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>
 ///     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;
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
 public ParserAssebly(IParserOptions options)
 {
     _options = options;
 }
Esempio n. 7
0
 internal Parser(IParserOptions parserOptions)
 {
     _parserOptions = parserOptions;
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        private static void WriteGlobalHelp(IDependencyResolverScope dependencyResolver, IParserOptions parserOptions)
        {
            var helpCommand = GetHelpCommand(dependencyResolver, parserOptions);

            helpCommand.Execute();
        }