in src/Hosting.Services/HostBuilderExtensions.cs [26:64]
public static IHost BuildStatelessService(
this IHostBuilder builder,
string serviceName,
Action<ServiceFabricHostBuilder<OmexStatelessService, StatelessServiceContext>> builderAction) =>
builder.BuildServiceFabricService<OmexStatelessServiceRegistrator, OmexStatelessService, StatelessServiceContext>(serviceName, builderAction);
/// <summary>
/// Configures host to run service fabric stateful service with initialized Omex dependencies
/// </summary>
public static IHost BuildStatefulService(
this IHostBuilder builder,
string serviceName,
Action<ServiceFabricHostBuilder<OmexStatefulService, StatefulServiceContext>> builderAction) =>
builder.BuildServiceFabricService<OmexStatefulServiceRegistrator, OmexStatefulService, StatefulServiceContext>(serviceName, builderAction);
/// <summary>
/// Registering Dependency Injection classes that will provide Service Fabric specific information for logging
/// </summary>
public static IServiceCollection AddOmexServiceFabricDependencies<TContext>(this IServiceCollection collection)
where TContext : ServiceContext
{
bool isStatefulService = typeof(StatefulServiceContext).IsAssignableFrom(typeof(TContext));
if (isStatefulService)
{
collection.TryAddAccessor<IReliableStateManager>();
collection.TryAddAccessor<IStatefulServicePartition, IServicePartition>();
}
else
{
collection.TryAddAccessor<IStatelessServicePartition, IServicePartition>();
}
collection.TryAddAccessor<TContext, ServiceContext>();
collection.TryAddSingleton<IServiceContext, OmexServiceFabricContext>();
collection.TryAddSingleton<IExecutionContext, ServiceFabricExecutionContext>();
return collection.AddOmexServices();
}