use IServerStartup rather than class naming convention to register server service class

This commit is contained in:
sbwalker
2024-03-09 07:53:58 -05:00
parent 9106f9676c
commit 4457487e2a
2 changed files with 6 additions and 11 deletions

View File

@ -291,7 +291,7 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (implementationType.AssemblyQualifiedName != null)
{
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}")); var serviceName = implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}");
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}"));
services.AddScoped(serviceType ?? implementationType, implementationType);
}
}
@ -303,14 +303,6 @@ namespace Microsoft.Extensions.DependencyInjection
if (implementationType.AssemblyQualifiedName != null)
{
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}"));
if (serviceType == null && implementationType.AssemblyQualifiedName.Contains("Services.Server"))
{
// module server services reference a common interface which is located in the client assembly
var serviceName = implementationType.AssemblyQualifiedName
// convert implementation type name to interface name and change Server assembly to Client
.Replace(".Services.Server", ".Services.I").Replace(".Server,", ".Client,");
serviceType = Type.GetType(serviceName);
}
services.AddTransient(serviceType ?? implementationType, implementationType);
}
}