/* * Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: SessionProvider * File: RuntimeSessionProvider.cs * * RuntimeSessionProvider.cs is part of SessionProvider which is part of the larger * VNLib collection of libraries and utilities. * * SessionProvider is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * SessionProvider is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ using System; using System.Threading; using System.Threading.Tasks; using VNLib.Net.Http; using VNLib.Utils.Resources; namespace VNLib.Plugins.Essentials.Sessions { internal sealed class RuntimeSessionProvider : ISessionProvider { private readonly Func _canProcessMethod; private readonly ISessionProvider _ref; public RuntimeSessionProvider(ISessionProvider externProvider) { _ref = externProvider; //Load canprocess method dynamically _canProcessMethod = ManagedLibrary.GetMethod>(externProvider, "CanProcess"); } /// public ValueTask GetSessionAsync(IHttpEvent entity, CancellationToken cancellationToken) => _ref.GetSessionAsync(entity, cancellationToken); /// public bool CanProcess(IHttpEvent ev) => _canProcessMethod(ev); } }