Ejemplo n.º 1
0
        /// <summary>
        /// Create a new instance.
        /// </summary>
        public Runtime()
        {
            var nameValidator = new NameValidator();
            var commandDescriptorGenerator = new CommandAttributeInspector();

            _commandRegistry = new CommandRegistry(nameValidator, commandDescriptorGenerator);

            _commandServices  = new CommandServices();
            _parser           = new Parser();
            _variableReplacer = new VariableReplacer();

            _sessionObjectTypes = new ScopedObjectRegistry();
            _sessionObjectTypes.Register <VariableCollection>();

            _commandRegistry.Register(typeof(Help));
            _commandRegistry.Register(typeof(Var));

            _commandServices.Register(_commandRegistry);
            _commandServices.Register <IPhraseDictionary>(new PhraseDictionary());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="commandRegistry">The commands that have been registered.</param>
        /// <param name="commandServices">The command services that have been registered.</param>
        /// <param name="sessionObjects">Objects available to the session.</summary>
        public CommandFactory(ICommandRegistry commandRegistry, ICommandServices commandServices, IScopedObjectRegistry sessionObjects)
        {
            if (commandRegistry == null)
            {
                throw new ArgumentNullException(nameof(commandRegistry));
            }

            if (commandServices == null)
            {
                throw new ArgumentNullException(nameof(commandServices));
            }

            if (sessionObjects == null)
            {
                throw new ArgumentNullException(nameof(sessionObjects));
            }

            _commandRegistry = commandRegistry;
            _commandServices = commandServices;
            _sessionObjects  = sessionObjects;
        }