create moduletypes in code

This commit is contained in:
2020-08-19 11:22:45 +02:00
parent 5dcf9eba2c
commit 3da0fa7b9e
11 changed files with 206 additions and 14 deletions
+48
View File
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using zero.Core.Entities;
namespace zero.Core.Options
{
public class ModuleOptions : ZeroBackofficeCollection<ModuleType>, IZeroCollectionOptions
{
public ModuleOptions()
{
}
public void Add<T>(ModuleType<T> moduleType) where T : Module, new()
{
Items.Add(ModuleType.Convert(moduleType));
}
public void Add<T>(string alias, string name, string description, string icon, string group = null, List<string> disallowedPageTypes = null) where T : Module, new()
{
Items.Add(new ModuleType(typeof(T))
{
Alias = alias,
Name = name,
Description = description,
Icon = icon,
Group = group,
DisallowedPageTypes = disallowedPageTypes ?? new List<string>()
});
}
public void Add(Type type, string alias, string name, string description, string icon, string group = null, List<string> disallowedPageTypes = null)
{
Items.Add(new ModuleType(type)
{
Alias = alias,
Name = name,
Description = description,
Icon = icon,
Group = group,
DisallowedPageTypes = disallowedPageTypes ?? new List<string>()
});
}
}
}