integration stuff
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user