Files
mixtape/zero.Core/Configuration/Integrations/IntegrationOptions.cs
T

40 lines
1014 B
C#
Raw Normal View History

2021-11-19 14:59:24 +01:00
using FluentValidation;
2021-11-20 13:52:28 +01:00
namespace zero.Configuration;
2021-11-19 14:59:24 +01:00
2021-11-24 15:49:25 +01:00
public class IntegrationOptions : List<IntegrationType>
2021-11-19 14:59:24 +01:00
{
public void Add<T>(IntegrationType<T> integration) where T : Integration, new()
{
2021-11-24 15:49:25 +01:00
Add(IntegrationType.Convert(integration));
2021-11-19 14:59:24 +01:00
}
public void Add<T>(string alias, string name, string description, List<string> tags = default, string imagePath = null, IValidator validator = null) where T : Integration, new()
{
2021-11-24 15:49:25 +01:00
Add(new IntegrationType(typeof(T))
2021-11-19 14:59:24 +01:00
{
Alias = alias,
Name = name,
Description = description,
ImagePath = imagePath,
Tags = tags,
Validator = validator
});
}
public void Add(Type type, string alias, string name, string description, List<string> tags = default, string imagePath = null, IValidator validator = null)
{
2021-11-24 15:49:25 +01:00
Add(new IntegrationType(type)
2021-11-19 14:59:24 +01:00
{
Alias = alias,
Name = name,
Description = description,
ImagePath = imagePath,
Tags = tags,
Validator = validator
});
}
}