fix tests, 1 fails in mathUtilTest, changing from float to double
This commit is contained in:
@@ -21,7 +21,7 @@ public static class DependencyInjectionRegistrator
|
||||
var groupedTypes = types.SelectMany(
|
||||
t =>
|
||||
{
|
||||
var attributes = (Injectable[])Attribute.GetCustomAttributes(t, typeof(Injectable))!;
|
||||
var attributes = (Injectable[])Attribute.GetCustomAttributes(t, typeof(Injectable));
|
||||
var registerableType = t;
|
||||
var registerableComponents = new List<RegisterableType>();
|
||||
foreach (var attribute in attributes)
|
||||
@@ -37,7 +37,7 @@ public static class DependencyInjectionRegistrator
|
||||
registerableType = registerableType.GetInterfaces()[0];
|
||||
}
|
||||
|
||||
registerableComponents.Add(new(registerableType, t, attribute));
|
||||
registerableComponents.Add(new RegisterableType(registerableType, t, attribute));
|
||||
}
|
||||
|
||||
return registerableComponents;
|
||||
@@ -62,19 +62,18 @@ public static class DependencyInjectionRegistrator
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Type> AllLoadedTypes;
|
||||
private static List<ConstructorInfo> AllConstructors;
|
||||
private static List<Type>? _allLoadedTypes;
|
||||
private static List<ConstructorInfo>? _allConstructors;
|
||||
|
||||
private static void RegisterGenericComponents(IServiceCollection builderServices, RegisterableType valueTuple)
|
||||
{
|
||||
if (AllLoadedTypes == null)
|
||||
AllLoadedTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes()).ToList();
|
||||
if (AllConstructors == null)
|
||||
AllConstructors = AllLoadedTypes.SelectMany(t => t.GetConstructors()).ToList();
|
||||
_allLoadedTypes ??= AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes()).ToList();
|
||||
_allConstructors ??= _allLoadedTypes.SelectMany(t => t.GetConstructors()).ToList();
|
||||
|
||||
var typeName = $"{valueTuple.RegisterableInterface.Namespace}.{valueTuple.RegisterableInterface.Name}";
|
||||
try
|
||||
{
|
||||
var matchedConstructors = AllConstructors.Where(
|
||||
var matchedConstructors = _allConstructors.Where(
|
||||
c => c.GetParameters()
|
||||
.Any(
|
||||
p => p.ParameterType.IsGenericType &&
|
||||
@@ -82,25 +81,25 @@ public static class DependencyInjectionRegistrator
|
||||
)
|
||||
);
|
||||
|
||||
if (matchedConstructors.Any())
|
||||
var constructorInfos = matchedConstructors.ToList();
|
||||
if (constructorInfos.Count == 0) return;
|
||||
|
||||
foreach (var matchedConstructor in constructorInfos)
|
||||
{
|
||||
foreach (var matchedConstructor in matchedConstructors)
|
||||
foreach (var parameterInfo in matchedConstructor.GetParameters()
|
||||
.Where(
|
||||
p => p.ParameterType.IsGenericType &&
|
||||
p.ParameterType.GetGenericTypeDefinition().FullName == typeName
|
||||
))
|
||||
{
|
||||
foreach (var parameterInfo in matchedConstructor.GetParameters()
|
||||
.Where(
|
||||
p => p.ParameterType.IsGenericType &&
|
||||
p.ParameterType.GetGenericTypeDefinition().FullName == typeName
|
||||
))
|
||||
{
|
||||
var parameters = parameterInfo.ParameterType.GetGenericArguments();
|
||||
var typedGeneric = valueTuple.TypeToRegister.MakeGenericType(parameters);
|
||||
RegisterComponent(
|
||||
builderServices,
|
||||
valueTuple.InjectableAttribute.InjectionType,
|
||||
parameterInfo.ParameterType,
|
||||
typedGeneric
|
||||
);
|
||||
}
|
||||
var parameters = parameterInfo.ParameterType.GetGenericArguments();
|
||||
var typedGeneric = valueTuple.TypeToRegister.MakeGenericType(parameters);
|
||||
RegisterComponent(
|
||||
builderServices,
|
||||
valueTuple.InjectableAttribute.InjectionType,
|
||||
parameterInfo.ParameterType,
|
||||
typedGeneric
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class SptWebApplicationLogger<T> : ISptLogger<T>
|
||||
|
||||
public SptWebApplicationLogger(ILoggerProvider provider)
|
||||
{
|
||||
_logger = provider.CreateLogger(typeof(T).FullName);
|
||||
_logger = provider.CreateLogger(typeof(T).FullName ?? "SPT Logger Default Name");
|
||||
}
|
||||
|
||||
public void LogWithColor(
|
||||
|
||||
+7
-8
@@ -1,5 +1,3 @@
|
||||
using System.Reflection;
|
||||
using Core.Annotations;
|
||||
using Core.Context;
|
||||
using Core.Models.External;
|
||||
using Core.Models.Spt.Config;
|
||||
@@ -36,7 +34,7 @@ public static class Program
|
||||
var serviceProvider = builder.Services.BuildServiceProvider();
|
||||
var watermark = serviceProvider.GetService<Watermark>();
|
||||
// Initialize Watermak
|
||||
watermark.Initialize();
|
||||
watermark?.Initialize();
|
||||
|
||||
// Initialize PreSptMods
|
||||
var preSptLoadMods = serviceProvider.GetServices<IPreSptLoadMod>();
|
||||
@@ -46,18 +44,19 @@ public static class Program
|
||||
}
|
||||
var appContext = serviceProvider.GetService<ApplicationContext>();
|
||||
// Add the Loaded Mod Assemblies for later
|
||||
appContext.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, assemblies);
|
||||
appContext?.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, assemblies);
|
||||
// This is the builder that will get use by the HttpServer to start up the web application
|
||||
appContext.AddValue(ContextVariableType.APP_BUILDER, builder);
|
||||
appContext?.AddValue(ContextVariableType.APP_BUILDER, builder);
|
||||
|
||||
// Get the Built app and run it
|
||||
var app = serviceProvider.GetService<App>();
|
||||
app.Run().Wait();
|
||||
app?.Run().Wait();
|
||||
|
||||
var httpConfig = serviceProvider.GetService<ConfigServer>().GetConfig<HttpConfig>();
|
||||
var httpConfig = serviceProvider.GetService<ConfigServer>()?.GetConfig<HttpConfig>();
|
||||
// When we application gets started by the HttpServer it will add into the AppContext the WebApplication
|
||||
// object, which we can use here to start the webapp.
|
||||
(appContext.GetLatestValue(ContextVariableType.WEB_APPLICATION).GetValue<WebApplication>()).Run($"http://{httpConfig.Ip}:{httpConfig.Port}");
|
||||
if (httpConfig != null)
|
||||
(appContext?.GetLatestValue(ContextVariableType.WEB_APPLICATION)?.GetValue<WebApplication>())?.Run($"http://{httpConfig.Ip}:{httpConfig.Port}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user