fix: register api explorer in sandbox host
This commit is contained in:
38
F4SDM42WebApi/F4SDM42DependencyRegistrator.cs
Normal file
38
F4SDM42WebApi/F4SDM42DependencyRegistrator.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user