Initial version

This commit is contained in:
2025-12-15 19:56:17 +01:00
parent c04107c9b8
commit d93d29522c
26 changed files with 1152 additions and 43 deletions

View File

@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<PackageId>EonaCat.DeterministicTime.AspNetCore</PackageId>
<Version>1.0.0</Version>
<Authors>EonaCat (Jeroen Saey)</Authors>
<Description>
ASP.NET Core integration for DeterministicTime.
</Description>
<PackageTags>aspnet;core;middleware;time;deterministic;</PackageTags>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>EonaCat.DeterministicTime.AspNetCore</Title>
<Company>EonaCat (Jeroen Saey)</Company>
<Product>EonaCat.DeterministicTime.AspNetCore</Product>
<Copyright>EonaCat (Jeroen Saey)</Copyright>
<PackageProjectUrl>https://git.saey.me/EonaCat/EonaCat.DeterministicTime</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<RepositoryUrl>https://git.saey.me/EonaCat/EonaCat.DeterministicTime</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="EonaCat.DeterministicTime" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Net.Http;
namespace EonaCat.DeterministicTime.AspNetCore;
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
public sealed class DeterministicTimeMiddleware
{
private readonly RequestDelegate _next;
public DeterministicTimeMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
using (TimeScope.Scaled(1.0))
{
await _next(context);
}
}
}
public static class DeterministicTimeMiddlewareExtensions
{
public static IApplicationBuilder UseDeterministicTime(
this IApplicationBuilder app)
{
return app.UseMiddleware<DeterministicTimeMiddleware>();
}
}

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"EonaCat.DeterministicTime.AspNet": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:56865;http://localhost:56866"
}
}
}