Files
mixtape/zero.Demo/Program.cs
T

73 lines
1.6 KiB
C#
Raw Normal View History

2021-12-10 23:11:26 +01:00
using zero;
using zero.Api;
using zero.Applications;
2021-12-15 15:34:05 +01:00
using zero.Architecture;
2021-12-10 23:11:26 +01:00
using zero.Backoffice;
using zero.Backoffice.DevServer;
using zero.Demo;
using zero.Localization;
2021-12-10 23:11:26 +01:00
using zero.Routing;
2021-12-11 17:34:42 +01:00
using zero.Spaces;
using zero.Stores;
2021-12-10 23:11:26 +01:00
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddTransient<IApplicationResolverHandler, DevApplicationResolverHandler>();
2021-12-12 15:41:51 +01:00
builder.Services
.AddZero(builder.Configuration)
.AddApi()
.AddBackoffice();
2021-12-10 23:11:26 +01:00
builder.Services.Configure<ZeroDevOptions>(opts =>
{
opts.Enabled = false;
});
2021-12-11 17:34:42 +01:00
builder.Services.Configure<FlavorOptions>(opts =>
{
opts.AddSpaceList<TeamMember>("team", "Team", "Members of our team", "fth-users", "spaces.team");
2021-12-15 21:22:00 +01:00
opts.Configure<Country>(x => x.CanUseWithoutFlavors = false);
opts.Add<Country, EuropeanCountry>("eu_country", "EU country", "A country within the European Union", "fth-globe");
opts.Add<Country, AmericanCountry>("usa_country", "USA", "A country in the United States", "fth-flag");
2021-12-11 17:34:42 +01:00
});
2021-12-15 15:34:05 +01:00
builder.Services.Configure<BlueprintOptions>(opts =>
{
opts.Add<Country>();
});
2021-12-10 23:11:26 +01:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseZero().WithEndpoints(x =>
{
2021-12-12 15:41:51 +01:00
//x.MapControllerRoute("default", "api/{controller}/{action=Index}/{id?}");
2021-12-13 12:21:15 +01:00
x.MapControllers();
2021-12-10 23:11:26 +01:00
x.MapRazorPages();
2021-12-13 13:40:04 +01:00
x.MapZeroApi();
x.MapZeroBackoffice();
2021-12-10 23:11:26 +01:00
x.MapZeroRoutes();
});
2021-12-12 15:41:51 +01:00
//app.UseZeroBackoffice();
app.Run();
public class EuropeanCountry : Country
{
public string EuName { get; set; }
}
public class AmericanCountry : Country
{
public string State { get; set; }
}