From 7a34c642cec8530a4bfb8e9a95647fda16341a2b Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Mon, 13 Apr 2026 12:42:11 +0200 Subject: [PATCH] remove type collection from context --- Finch/Context/FinchContext.cs | 68 ++++++----------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/Finch/Context/FinchContext.cs b/Finch/Context/FinchContext.cs index 57ae398e..0aaf6bea 100644 --- a/Finch/Context/FinchContext.cs +++ b/Finch/Context/FinchContext.cs @@ -1,42 +1,23 @@ using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; namespace Finch.Context; -public class FinchContext : IFinchContext +public class FinchContext( + IFinchOptions options, + ICultureResolver cultureResolver, + IServiceProvider services) + : IFinchContext { /// - public IFinchOptions Options { get; protected set; } + public IFinchOptions Options { get; } = options; + /// - public IServiceProvider Services { get; } - - protected ICultureResolver CultureResolver { get; } - - protected ILogger Logger { get; private set; } - - protected IHandlerHolder Handler { get; private set; } - - protected IHttpContextAccessor HttpContextAccessor { get; private set; } - - protected IPrimitiveTypeCollection ValueCollection { get; } + public IServiceProvider Services { get; } = services; bool _resolved = false; - public FinchContext(IFinchOptions options, IHttpContextAccessor httpContextAccessor, ICultureResolver cultureResolver, - ILogger logger, IHandlerHolder handler, IServiceProvider services) - { - Options = options; - CultureResolver = cultureResolver; - Logger = logger; - Handler = handler; - ValueCollection = new PrimitiveTypeCollection(); - HttpContextAccessor = httpContextAccessor; - Services = services; - } - - /// public virtual async Task Resolve(HttpContext context) { @@ -45,23 +26,11 @@ public class FinchContext : IFinchContext return; } - _resolved = true; - // set current culture - await CultureResolver.Resolve(this); + await cultureResolver.Resolve(this); + + _resolved = true; } - - - /// - public T Get() => ValueCollection.Get(); - - - /// - public void Set(T value) => ValueCollection.Set(value); - - - /// - public void Remove() => ValueCollection.Remove(); } @@ -83,19 +52,4 @@ public interface IFinchContext /// the currently active backoffice user, as users are not signed in with the default scheme and do therefore not populate HttpContext.User /// Task Resolve(HttpContext context); - - /// - /// Get a custom property from this scoped context - /// - T Get(); - - /// - /// Add a custom property to this scoped context - /// - void Set(T value); - - /// - /// Remove a custom property from this scoped context - /// - void Remove(); } \ No newline at end of file