You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Recyclarr.TrashLib/Config/Parsing/ConfigRegistry.cs

25 lines
753 B

using Recyclarr.Common.Extensions;
using Recyclarr.TrashLib.Config.Services;
namespace Recyclarr.TrashLib.Config.Parsing;
public class ConfigRegistry : IConfigRegistry
{
private readonly Dictionary<SupportedServices, List<ServiceConfiguration>> _configs = new();
public void Add(SupportedServices configType, ServiceConfiguration config)
{
_configs.GetOrCreate(configType).Add(config);
}
public IReadOnlyCollection<T> GetConfigsOfType<T>(SupportedServices serviceType) where T : ServiceConfiguration
{
return _configs[serviceType].Cast<T>().ToList();
}
public bool DoesConfigExist(string name)
{
return _configs.Values.Any(x => x.Any(y => y.InstanceName.EqualsIgnoreCase(name)));
}
}