implement client and server service implementations in Html/Text module

This commit is contained in:
sbwalker
2024-03-05 08:44:09 -05:00
parent 7d7ea4c34b
commit 74952cf62d
11 changed files with 214 additions and 30 deletions

View File

@ -292,11 +292,29 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (implementationType.AssemblyQualifiedName != null)
{
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}"));
var serviceType = Type.GetType(implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}")); var serviceName = implementationType.AssemblyQualifiedName.Replace(implementationType.Name, $"I{implementationType.Name}");
services.AddScoped(serviceType ?? implementationType, implementationType);
}
}
// dynamically register module server scoped services (using conventions)
implementationTypes = assembly.GetInterfaces<IServerService>();
foreach (var implementationType in implementationTypes)
{
if (implementationType.AssemblyQualifiedName != 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,");
var serviceType = Type.GetType(serviceName);
if (serviceType != null)
{
services.AddScoped(serviceType, implementationType);
}
}
}
// dynamically register module transient services (ie. server DBContext, repository classes)
implementationTypes = assembly.GetInterfaces<ITransientService>();
foreach (var implementationType in implementationTypes)