public static IServiceCollection AddGrpcServer <TServiceInterface, TServiceImplementation>( this IServiceCollection serviceCollection, GrpcServerOptions options ) where TServiceInterface : class, IGrpcService where TServiceImplementation : class, IGrpcService, TServiceInterface { return(serviceCollection.AddGrpcServer <TServiceInterface, TServiceImplementation>(options, Serializer)); }
public static IServiceCollection AddGrpcServer <TServiceInterface, TServiceImplementation>( this IServiceCollection serviceCollection, GrpcServerOptions options, ISerializer serializer ) where TServiceInterface : class, IGrpcService where TServiceImplementation : class, IGrpcService, TServiceInterface { serviceCollection.AddScoped <TServiceInterface, TServiceImplementation>(); serviceCollection.AddSingleton <GrpcHost <TServiceInterface> >( appServices => GrpcHostFactory.Create <TServiceInterface>(appServices, options, serializer) ); serviceCollection.AddSingleton <IHostedService, GrpcBackgroundService <TServiceInterface> >(); return(serviceCollection); }