From d1b41814a23dc46081beb2bb245ca7409754b26e Mon Sep 17 00:00:00 2001 From: Meik Date: Wed, 1 Jul 2026 01:20:19 +0200 Subject: [PATCH] fix: register api explorer in sandbox host --- .../C4ITF4SDM42WebApi.dll.host.config | 1 + F4SDM42WebApi/F4SD - M42WebApi.csproj | 7 +++- F4SDM42WebApi/F4SDM42DependencyRegistrator.cs | 38 +++++++++++++++++++ F4SDM42WebApi/F4SDM42WebApiController.cs | 2 +- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 F4SDM42WebApi/F4SDM42DependencyRegistrator.cs diff --git a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config index 01bb731..43bcaec 100644 --- a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config +++ b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config @@ -1,6 +1,7 @@ + diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index 88aaaa6..26e5c1a 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.32 + 1.4.0.33 true @@ -66,6 +66,10 @@ M42Libraries\26.1\System.Net.Http.Formatting.dll false + + M42Libraries\26.1\System.Web.Http.dll + false + M42Libraries\26.1\update4u.SPS.DataLayer.dll false @@ -82,6 +86,7 @@ + diff --git a/F4SDM42WebApi/F4SDM42DependencyRegistrator.cs b/F4SDM42WebApi/F4SDM42DependencyRegistrator.cs new file mode 100644 index 0000000..f74fd33 --- /dev/null +++ b/F4SDM42WebApi/F4SDM42DependencyRegistrator.cs @@ -0,0 +1,38 @@ +using System; +using System.Web.Http; +using System.Web.Http.Description; + +using Matrix42.Hosting.Contracts; + +using C4IT.Logging; + +using static C4IT.Logging.cLogManager; + +namespace C4IT.F4SD +{ + public class F4SDM42DependencyRegistrator : IDependencyRegistrator + { + public void Register(IDependencyContainer container, IDependencyResolver resolver) + { + if (container == null) + throw new ArgumentNullException(nameof(container)); + + if (resolver == null) + throw new ArgumentNullException(nameof(resolver)); + + try + { + if (resolver.TryGet(typeof(IApiExplorer)) != null) + return; + } + catch + { + // Existing mapping is incomplete in the sandbox host. Register a concrete instance below. + } + + var httpConfiguration = new HttpConfiguration(); + container.RegisterInstance(typeof(IApiExplorer), new ApiExplorer(httpConfiguration)); + LogEntry("Registered System.Web.Http.Description.IApiExplorer for Matrix42 sandbox host.", LogLevels.Debug); + } + } +} diff --git a/F4SDM42WebApi/F4SDM42WebApiController.cs b/F4SDM42WebApi/F4SDM42WebApiController.cs index f78f88b..e4d50d5 100644 --- a/F4SDM42WebApi/F4SDM42WebApiController.cs +++ b/F4SDM42WebApi/F4SDM42WebApiController.cs @@ -308,7 +308,7 @@ namespace C4IT.F4SD Values = vals.ToArray() }; //CacheOutputAttribute.RegisterResponseEtag($"enum_{enumeration.Name}_{(int)mode}", $"{enumeration.Name}_{(int)mode}", cultureInvariant: false, userInvariant: true, val); - return Request.CreateResponse(HttpStatusCode.OK, enumeration); + return Matrix42.WebApi.Contracts.HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.OK, enumeration); } [Route("getMyRoleMemberships"), HttpGet]