Files
InServiceQue/InServiceQue/Services/QueueTypeRegistry.cs

21 lines
600 B
C#

using Microsoft.Extensions.DependencyInjection;
namespace InServiceQue.Services;
public class QueueTypeRegistry: ITypeRegistry
{
private static Dictionary<string, Type> _typeRegistry = new Dictionary<string, Type>();
public void RegisterTaskType(string taskType, Type type)
{
_typeRegistry.Add(taskType, type);
}
public IQueueHandler GetService(IServiceScope scope, string taskType)
{
var classType = _typeRegistry[taskType];
var service = scope.ServiceProvider.GetService(classType);
return (IQueueHandler)service;
}
}