Esempio n. 1
0
        public ComponentRegistryService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            MessageBusService messageBusService,
            AppService appService,
            ComponentInitializerService componentInitializerService,
            ILogger <ComponentRegistryService> logger)
        {
            _storageService              = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService           = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _componentInitializerService = componentInitializerService ?? throw new ArgumentNullException(nameof(componentInitializerService));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _messageBusWrapper = new ComponentRegistryMessageBusWrapper(messageBusService);

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("component_registry.count", () => _components.Count);

            if (appService is null)
            {
                throw new ArgumentNullException(nameof(appService));
            }
            appService.RegisterStatusProvider("components", () =>
            {
                return(GetComponents().Select(c => ComponentsController.CreateComponentModel(c)));
            });
        }
        public ComponentRegistryService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            MessageBusService messageBusService,
            ComponentInitializerService componentInitializerService,
            ILoggerFactory loggerFactory)
        {
            _storageService              = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _messageBusService           = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _componentInitializerService = componentInitializerService ?? throw new ArgumentNullException(nameof(componentInitializerService));

            _messageBusProxy = new ComponentRegistryMessageBusProxy(messageBusService);

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <ComponentRegistryService>();

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("component_registry.count", () => _components.Count);
        }