using FluentValidation; using System.Collections.Generic; using zero.Core.Entities; using zero.Core.Mapper; using zero.Core.Plugins; using zero.Core.Renderer; namespace zero.Core.Options { public class ZeroOptions : IZeroOptions { public ZeroOptions() { SupportedLanguages = new string[2] { "en-US", "de-DE" }; DefaultLanguage = SupportedLanguages[0]; TokenExpiration = 60; BackofficePath = "/zero"; Sections = new SectionOptions(); Features = new FeatureOptions(); Pages = new PageOptions(); Permissions = new PermissionOptions(); Renderers = new RendererOptions(); Settings = new SettingsOptions(); Spaces = new SpaceOptions(); Mapper = new MapperOptions(); Types = new TypeOptions(); } /// public string ZeroVersion { get; set; } /// public string DefaultLanguage { get; set; } /// public string[] SupportedLanguages { get; private set; } /// public int TokenExpiration { get; set; } /// public RavenOptions Raven { get; set; } /// public string BackofficePath { get; set; } /// //public IZeroPluginConfiguration Backoffice { get; set; } /// public SectionOptions Sections { get; private set; } /// public FeatureOptions Features { get; private set; } /// public PageOptions Pages { get; private set; } /// public PermissionOptions Permissions { get; private set; } /// public RendererOptions Renderers { get; private set; } /// public SettingsOptions Settings { get; private set; } /// public SpaceOptions Spaces { get; private set; } /// public MapperOptions Mapper { get; private set; } /// public TypeOptions Types { get; private set; } /// public void Extend() where TTarget : class, T { Types.Add(); } public ZeroExtend Extend() where T : class, IZeroEntity { return new ZeroExtend(); } } public class RavenOptions { public string Url { get; set; } public string Database { get; set; } } public interface IZeroOptions { /// /// The currently active version /// This should not be set manually, as it is used for setup and migrations and incremented automatically /// string ZeroVersion { get; set; } /// /// Default language ISO code /// string DefaultLanguage { get; set; } /// /// Language ISO codes which are supported by the zero backoffice /// string[] SupportedLanguages { get; } /// /// Expiration in minutes of a generated change token for an entity /// int TokenExpiration { get; set; } /// /// RavenDB configuration data /// RavenOptions Raven { get; set; } /// /// URL path to the backoffice (defaults to /zero) /// string BackofficePath { get; set; } /// /// /// SectionOptions Sections { get; } /// /// /// FeatureOptions Features { get; } /// /// /// PageOptions Pages { get; } /// /// /// PermissionOptions Permissions { get; } /// /// /// RendererOptions Renderers { get; } /// /// /// SettingsOptions Settings { get; } /// /// /// SpaceOptions Spaces { get; } /// /// /// MapperOptions Mapper { get; } /// /// /// TypeOptions Types { get; } /// void Extend() where TTarget : class, T; ZeroExtend Extend() where T : class, IZeroEntity; /// /// Default settings for the backoffice /// //IZeroPluginConfiguration Backoffice { get; set; } } public class ZeroExtend where T : IZeroEntity { public ZeroExtend Use() where TTarget : class, T { return this; } public ZeroExtend Use() where TTarget : class, T where TRenderer : IRenderer { return this; } public ZeroExtend Use() where TTarget : class, T where TRenderer : IRenderer where TValidator : IValidator { return this; } public ZeroExtend Use() where TTarget : class, T where TRenderer : IRenderer where TValidator : IValidator where TMapper : IMapperConfig { return this; } public ZeroExtend UseRenderer() where TRenderer : IRenderer { return this; } public ZeroExtend UseValidator() where TValidator : IRenderer { return this; } public ZeroExtend UseMapper() where TMapper : IRenderer { return this; } } }