Текущая ситуация выглядит следующим образом:
Код: Выделить всё
public interface IMessageProcessor
{
Task ProcessMessageAsync(TMessage message, string tableConfig);
}
public class MessageProcessorA : IMessageProcessor
{
public Task ProcessMessageAsync(MessageA message, string tableConfig)
}
public class MessageProcessorB : IMessageProcessor
{
public Task ProcessMessageAsync(MessageB message, string tableConfig)
}
Код: Выделить всё
builder.Services
// Register all message processors
.AddSingleton(serviceProvider => supplierType =>
{
return supplierType switch
{
SupplierType.A => serviceProvider.GetRequiredService(),
SupplierType.B => serviceProvider.GetRequiredService(),
_ => throw new NotImplementedException(),
};
})
РЕДАКТИРОВАТЬ: я никогда не реализовал концепцию блока DataFlow, я попробую реализовать ее и посмотрю, смогу ли я в этом разобраться. Выглядит интересно
Подробнее здесь: https://stackoverflow.com/questions/798 ... neric-type
Мобильная версия