/// <summary>
        /// Initializes a new instance of the <see cref="Brick"/> class.
        /// </summary>
        /// <param name="communicationFactory">Object implementing the <see cref="ICommunicationFactory"/> interface.</param>
        /// <param name="fileProvider">Object implementing the <see cref="IFileProvider"/> interface.</param>
        /// <param name="alwaysSendEvents">Send events when data changes, or at every poll</param>
        public Brick(ICommunicationFactory communicationFactory, IFileProvider fileProvider, bool alwaysSendEvents = false)
        {
            DirectCommandFactory = new DirectCommandFactory(this);
            SystemCommandFactory = new SystemCommandFactory(this, fileProvider);
            BatchCommandFactory  = new BatchCommandFactory(this);

            Buttons = new BrickButtons();

            _communicationFactory = communicationFactory;
            _alwaysSendEvents     = alwaysSendEvents;

            int index = 0;

            Ports = new Dictionary <InputPort, Port>();

            foreach (InputPort i in Enum.GetValues(typeof(InputPort)))
            {
                Ports[i] = new Port
                {
                    InputPort = i,
                    Index     = index++,
                    Name      = i.ToString(),
                };
            }
        }
Esempio n. 2
0
        public CleeEngine(ICommandRegistry commandRegistry, ICommandFactory commandFactory, 
            IArgumentMapper argumentMapper, ICommandExecutor commandExecutor)
        {
            _registry = commandRegistry;
            _commandFactory = commandFactory;
            _mapper = argumentMapper;
            _commandExecutor = commandExecutor;

            _systemRegistry = SystemCommandRegistry.CreateAndInitialize(); // this should be removed from the constructor!

            _systemCommandFactory = new SystemCommandFactory();
            _systemCommandFactory.RegisterInstance<ICommandRegistry>(_registry);
            _systemCommandFactory.RegisterInstance<ICommandFactory>(_commandFactory);
            _systemCommandFactory.RegisterInstance<IArgumentMapper>(_mapper);
            _systemCommandFactory.RegisterInstance<ICommandExecutor>(_commandExecutor);
            _systemCommandFactory.RegisterInstance<SystemCommandRegistry>(_systemRegistry);
            _systemCommandFactory.RegisterFactoryMethod<IOutputWriter>(() => _outputWriter);
            _systemCommandFactory.RegisterInstance(_settings);

            _history = new LinkedList<HistoryEntry>();
            _outputWriter = new DefaultOutputWriter();
        }
Esempio n. 3
0
        public CleeEngine(ICommandRegistry commandRegistry, ICommandFactory commandFactory,
                          IArgumentMapper argumentMapper, ICommandExecutor commandExecutor)
        {
            _registry        = commandRegistry;
            _commandFactory  = commandFactory;
            _mapper          = argumentMapper;
            _commandExecutor = commandExecutor;

            _systemRegistry = SystemCommandRegistry.CreateAndInitialize(); // this should be removed from the constructor!

            _systemCommandFactory = new SystemCommandFactory();
            _systemCommandFactory.RegisterInstance <ICommandRegistry>(_registry);
            _systemCommandFactory.RegisterInstance <ICommandFactory>(_commandFactory);
            _systemCommandFactory.RegisterInstance <IArgumentMapper>(_mapper);
            _systemCommandFactory.RegisterInstance <ICommandExecutor>(_commandExecutor);
            _systemCommandFactory.RegisterInstance <SystemCommandRegistry>(_systemRegistry);
            _systemCommandFactory.RegisterFactoryMethod <IOutputWriter>(() => _outputWriter);
            _systemCommandFactory.RegisterInstance(_settings);

            _history          = new LinkedList <HistoryEntry>();
            _outputWriter     = new DefaultOutputWriter();
            _exitCodeAssigner = exitCode => Environment.ExitCode = exitCode;
        }