// ReSharper disable once TooManyDependencies public Building(IElevator elevator, ILogger <Building> logger, ISettingsService settingsService, IEventStreamService eventStreamService) { _logger = logger; Floors = new Dictionary <int, IFloor>(); for (var i = 0; i < settingsService.FloorCount; i++) { Floors.Add(i, new Floor(i, settingsService.MaxPersonsPerBuilding / settingsService.FloorCount)); } Elevator = elevator; _controlParameterSubscription = eventStreamService.ControlParameterObservable.Subscribe(cp => { if (string.Compare(cp.ParameterName, "MaxPersonsPerBuilding", StringComparison.OrdinalIgnoreCase) != 0) { return; } if (!int.TryParse(cp.ParameterValue.ToString(), out var personsPerBuilding)) { return; } var personsPerFloor = personsPerBuilding / settingsService.FloorCount; Floors.Values.ToList().ForEach(f => f.MaxPersons = personsPerFloor); }); }
// ReSharper disable once TooManyDependencies public OutputService(IBuilding building, IElevator elevator, ILogger <OutputService> logger, IEventStreamService eventStreamService, IHubContext <ElevatorHub, IElevatorHub> hub, ISettingsService settingsService) { _building = building; _logger = logger; _eventStreamService = eventStreamService; _hub = hub; _elevator = elevator; _settingsService = settingsService; _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; _building.SubscribeToPersonActions(personAction => { _history.Add(personAction); if (_history.Count > 100) { _history.RemoveAt(0); } }, _token); _eventStreamService.SubscribeToGeneration(genAction => { if (genAction == "FINISHED") { _logger.LogInformation($"History count: {_history.Count}"); } }, _token); _elevator.SubscribeToElevatorActions(OnElevatorAction); }
/// <summary> /// Initializes a new instance of the <see cref="InputValueChangedEventController" /> class. /// </summary> /// <param name="service">The <see cref="EventStreamService "/> instance. /// </param> public InputValueChangedEventController(IEventStreamService service) { if (service == null) { throw new ArgumentNullException(nameof(service)); } this._service = service; }
/// <summary> /// Initializes a new instance of the <see cref="HomeController" /> class. /// </summary> /// <param name="service">The <see cref="EventStreamService" /> instance.</param> public HomeController(IEventStreamService service) { if (service == null) { throw new ArgumentNullException(nameof(service)); } this._service = service; this.HttpContext = base.HttpContext; }
/// <summary> /// Initialize a new instance of the <see cref="JournalVoucherController" /> class /// </summary> /// <param name="repository"><c>SapQueryRepository</c> instance</param> /// <param name="service"><c>EventStreamService</c> instance</param> public JournalVoucherController(ISapQueryRepository repository, IEventStreamService service) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } this._repository = repository; if (service == null) { throw new ArgumentNullException(nameof(service)); } this._service = service; }
/// <summary> /// Initialises a new instance of the <see cref="CountryController" /> class. /// </summary> /// <param name="queryRepository"><c>SapQueryRepository</c> instance.</param> /// <param name="service"><c>EventStreamService</c> instance.</param> public CountryController(ISapQueryRepository queryRepository, IEventStreamService service) { if (queryRepository == null) { throw new ArgumentNullException(nameof(queryRepository)); } this._queryRepository = queryRepository; if (service == null) { throw new ArgumentNullException(nameof(service)); } this._service = service; }
public InMemoryEventStore(IMediator mediator, IEventStreamService eventStreamService) { this.mediator = mediator; this.eventStreamService = eventStreamService; }
public ElevatorHub(ISettingsService settingsService, IEventStreamService eventStreamService) { _settingsService = settingsService; _eventStreamService = eventStreamService; }