integration stuff

This commit is contained in:
2021-12-22 15:41:11 +01:00
parent 790791d919
commit 8de62e30f6
33 changed files with 587 additions and 135 deletions
@@ -4,7 +4,7 @@ namespace zero.Configuration;
public class IntegrationOptions : List<IntegrationType>
{
public void Add<T>(string alias, string name, string description, string editorAlias = null, List<string> tags = default, string imagePath = null, IValidator validator = null) where T : IntegrationModel, new()
public void Add<T>(string alias, string name, string description, string editorAlias = null, List<string> tags = default, string imagePath = null, IValidator validator = null) where T : Integration , new()
{
Add(new IntegrationType(typeof(T))
{
@@ -22,6 +22,11 @@ public class IntegrationOptions : List<IntegrationType>
public void Add(Type type, string alias, string name, string description, string editorAlias = null, List<string> tags = default, string imagePath = null, IValidator validator = null)
{
if (!typeof(Integration).IsAssignableFrom(type))
{
throw new ArgumentException("Type has to inherit the Integration base model", nameof(type));
}
Add(new IntegrationType(type)
{
Alias = alias,
@@ -30,7 +35,7 @@ public class IntegrationOptions : List<IntegrationType>
ImagePath = imagePath,
Tags = tags,
Validator = validator,
Construct = cfg => Activator.CreateInstance(type),
Construct = cfg => Activator.CreateInstance(type) as Integration,
EditorAlias = editorAlias
});
}