Extract AspNetCore dependency to VAR.WebFormsCore.AspNetCore.

* Abstract HttpContext with IWebContext.
* Move AspNetCore dependant code to isolated classes.
* Downgrade VAR.WebFormsCore to netstandard2.0.
This commit is contained in:
2023-05-28 04:33:44 +02:00
parent f52d80e643
commit 1eb0fea182
53 changed files with 1847 additions and 1708 deletions

View File

@@ -1,3 +1,4 @@
using System;
using VAR.WebFormsCore.Code;
using VAR.WebFormsCore.Controls;
using VAR.WebFormsCore.Pages;

View File

@@ -1,17 +1,12 @@
namespace VAR.WebFormsCore.TestWebApp
{
public static class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
using VAR.WebFormsCore.AspNetCore;
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
namespace VAR.WebFormsCore.TestWebApp;
public static class Program
{
public static void Main(string[] args)
{
DefaultMain.WebFormCoreMain(args);
}
}
}

View File

@@ -1,22 +0,0 @@
using Microsoft.AspNetCore.Server.Kestrel.Core;
using VAR.WebFormsCore.Code;
namespace VAR.WebFormsCore.TestWebApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// If using Kestrel:
services.Configure<KestrelServerOptions>(options =>
{
options.AddServerHeader = false;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseGlobalRouterMiddleware(env);
}
}
}

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using VAR.WebFormsCore.Code;
namespace VAR.WebFormsCore.TestWebApp;
@@ -14,12 +15,12 @@ public class TestWebAppGlobalConfig : IGlobalConfig
public List<string> AllowedExtensions { get; } = new()
{ ".png", ".jpg", ".jpeg", ".gif", ".ico", ".wav", ".mp3", ".ogg", ".mp4", ".webm", ".webp", ".mkv", ".avi" };
public bool IsUserAuthenticated(HttpContext context)
public bool IsUserAuthenticated(IWebContext context)
{
return false;
}
public void UserDeauthenticate(HttpContext context)
public void UserDeauthenticate(IWebContext context)
{
}
}

View File

@@ -3,10 +3,10 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\VAR.WebFormsCore.AspNetCore\VAR.WebFormsCore.AspNetCore.csproj" />
<ProjectReference Include="..\VAR.WebFormsCore\VAR.WebFormsCore.csproj" />
</ItemGroup>