Skip to content

Commit

Permalink
Switch to top level class
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Dec 7, 2023
1 parent 6efec4c commit 55d608a
Showing 1 changed file with 66 additions and 74 deletions.
140 changes: 66 additions & 74 deletions src/MyApplication.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,107 +8,99 @@
using Moryx.Model;
using Moryx.Runtime.Kernel;
using Moryx.Tools;
using MyApplication.App;
using System.Globalization;
using System.IO;
using System.Text.Json.Serialization;

namespace MyApplication.App
AppDomainBuilder.LoadAssemblies();

var builder = WebApplication.CreateBuilder();
var services = builder.Services;

// Setup MORYX
services.AddMoryxKernel();
services.AddMoryxModels();
services.AddMoryxModules();

#region Startup ConfigureServices
services.AddSingleton<IAuthorizationPolicyProvider, ExamplePolicyProvider>();

services.AddLocalization();
services.Configure<RequestLocalizationOptions>(options =>
{
public class Program
var supportedCultures = new[]
{
public static void Main(string[] args)
{
AppDomainBuilder.LoadAssemblies();

var builder = WebApplication.CreateBuilder();
var services = builder.Services;

// Setup MORYX
services.AddMoryxKernel();
services.AddMoryxModels();
services.AddMoryxModules();

#region Startup ConfigureServices
services.AddSingleton<IAuthorizationPolicyProvider, ExamplePolicyProvider>();

services.AddLocalization();
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[]
{
new CultureInfo("de-De"),
new CultureInfo("en-De"),
new CultureInfo("it-De"),
new CultureInfo("zh-Hans"),
};
};

options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});


services.AddCors(options =>
{
options.AddPolicy("CorsPolicy", builder => builder
.WithOrigins("http://localhost:4200") // Angular app url for testing purposes
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy", builder => builder
.WithOrigins("http://localhost:4200") // Angular app url for testing purposes
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});

services.AddRazorPages();
services.AddRazorPages();

services.AddControllers()
.AddJsonOptions(jo => jo.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
services.AddControllers()
.AddJsonOptions(jo => jo.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));

services.AddSwaggerGen(c =>
{
c.CustomOperationIds(api => ((ControllerActionDescriptor)api.ActionDescriptor).MethodInfo.Name);
c.CustomSchemaIds(type => type.ToString());
});
#endregion
services.AddSwaggerGen(c =>
{
c.CustomOperationIds(api => ((ControllerActionDescriptor)api.ActionDescriptor).MethodInfo.Name);
c.CustomSchemaIds(type => type.ToString());
});
#endregion

var app = builder.Build();
var env = app.Environment;
var app = builder.Build();
var env = app.Environment;

#region Startup Configure App
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
#region Startup Configure App
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseRequestLocalization();
app.UseRequestLocalization();

app.UseStaticFiles();
app.UseStaticFiles();

app.UseHttpsRedirection();
app.UseHttpsRedirection();

app.UseRouting();
app.UseRouting();

if (env.IsDevelopment())
app.UseCors("CorsPolicy");
if (env.IsDevelopment())
app.UseCors("CorsPolicy");

app.UseAuthentication();
app.UseAuthorization();
app.UseAuthentication();
app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
var conventionBuilder = endpoints.MapControllers();
conventionBuilder.WithMetadata(new AllowAnonymousAttribute());
app.UseEndpoints(endpoints =>
{
var conventionBuilder = endpoints.MapControllers();
conventionBuilder.WithMetadata(new AllowAnonymousAttribute());

endpoints.MapRazorPages();
});
#endregion
endpoints.MapRazorPages();
});
#endregion

app.Services.UseMoryxConfigurations("Config");
app.Services.StartMoryxModules();
app.Services.UseMoryxConfigurations("Config");
app.Services.StartMoryxModules();

app.Run();
app.Run();

app.Services.StopMoryxModules();
}
}
}
app.Services.StopMoryxModules();

0 comments on commit 55d608a

Please sign in to comment.