Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Ev.ServiceBus/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,21 @@ private static void RegisterResourceManagementServices(IServiceCollection servic
services.TryAddSingleton<ReceiverWrapperFactory>();
services.TryAddSingleton<IClientFactory, ClientFactory>();

if (services.Any(o => o.ImplementationType == typeof(ServiceBusHost)) == false)
if (!HasImplementationType(services, typeof(ServiceBusHost)))
{
services.AddHostedService<ServiceBusHost>();
}
}

private static bool HasImplementationType(IServiceCollection services, Type implementationType)
{
return services.Any(s =>
#if NET8_0_OR_GREATER
s.ServiceKey is null &&
#endif
s.ImplementationType == implementationType);
}

/// <summary>
/// The start of the registration process for message reception
/// </summary>
Expand Down