Files
mixtape/zero.Core/Options/IntegrationOptions.cs
T

44 lines
1.2 KiB
C#
Raw Normal View History

2021-01-13 23:50:03 +01:00
using FluentValidation;
using System;
using System.Collections.Generic;
2020-12-10 15:57:59 +01:00
using zero.Core.Integrations;
namespace zero.Core.Options
{
2021-01-13 23:50:03 +01:00
public class IntegrationOptions : ZeroBackofficeCollection<IntegrationType>, IZeroCollectionOptions
2020-12-10 15:57:59 +01:00
{
2021-01-13 23:50:03 +01:00
public void Add<T>(IntegrationType<T> integration) where T : Integration, new()
2020-12-10 15:57:59 +01:00
{
2021-01-13 23:50:03 +01:00
Items.Add(IntegrationType.Convert(integration));
}
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-01-13 23:50:03 +01:00
{
Items.Add(new IntegrationType(typeof(T))
{
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-01-13 23:50:03 +01:00
{
Items.Add(new IntegrationType(type)
{
Alias = alias,
Name = name,
Description = description,
ImagePath = imagePath,
Tags = tags,
Validator = validator
});
2020-12-10 15:57:59 +01:00
}
}
}