ServiceResolver.GenericHost is an abstract library for .NET generic host, using ServiceResolver.Ioc integration.
$ dotnet add package ServiceResolver.GenericHostServiceResolver.GenericHost is an abstract library for .NET generic host, which uses ServiceResolver.Ioc library.
// your custom Service resolver provider (or other third party IServiceRegisterProvider implementation).
class CustomServiceRegisterProvider : IServiceRegisterProvider
{
public CustomServiceRegisterProvider(CustomServiceRegisterDescriptor descriptor)
{
// coding for setup.
}
// your custom implementation ..
}
var hostBuilder = Host.CreateDefaultBuilder(args)
// custom extension method to use for integration.
.UseServiceResolver(new ServiceRegisterOptions<IServiceRegisterProvider>
{
// a factory use to create your service register provider (implements IServiceRegisterProvider)
OnCreating = collection =>
{
return new CustomServiceRegisterProvider(new CustomServiceRegisterDescriptor());
},
// (optional)
// an action uses to prepare (if needed) your IServiceCollection.
BeforeRegistering = collection =>
{
// your IServiceCollection registrations or integrations
},
// an action uses to register your services.
OnRegistering = provider =>
{
// example:
provider.Register<StringBuilder>(() => new StringBuilder("hello world.."));
},
// (optional)
// an action uses to executes custom action at the end of all previous steps.
AfterBuildingProvider = provider =>
{
}
});
var host = hostBuilder
.Build();
await host.RunAsync();