/// <summary> /// Start component /// </summary> /// <param name="componentId"></param> /// <returns></returns> public async Task <bool> StartComponent(string componentId) { var component = AvailableComponents.FirstOrDefault(c => string.Equals(c.Id, componentId, StringComparison.CurrentCultureIgnoreCase)); if (component == null) { return(false); } if (RunningComponents.FirstOrDefault(c => c.Id == componentId) == null) { await StartComponent(component, _componentsTypes[component]); } return(true); }
private void ScanComponents() { _logger.LogInformation("Scanning for components"); AssemblyUtils.ScanAllAssembliesFromAttribute(typeof(ComponentAttribute)).ForEach(t => { try { var attr = t.GetCustomAttribute <ComponentAttribute>(); var componentInfo = new ComponentInfo { Id = attr.Id, Name = attr.Name, Version = attr.Version, Description = attr.Description }; AvailableComponents.Add(componentInfo); _componentsTypes.Add(componentInfo, t); } catch (Exception ex) { _logger.LogError($"Error during initialize component {t.Name} => {ex}"); } }); }