Files
C4IT-F4SD-M42WebApi/F4SDM42WebApi/F4SDM42DependencyRegistrator.cs
2026-07-01 01:20:19 +02:00

39 lines
1.2 KiB
C#

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);
}
}
}