急于在 ASP.net Core 3.1 中加载 GRPC 端点

Eager loading GRPC Endpoints in ASP.net Core 3.1

有没有办法预先加载 GRPC 端点,以便 class' 服务在应用程序启动时解析?我目前这样注册 GRPC 端点:

public class Startup {

    ...

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
      if (env.IsDevelopment()) {
        app.UseDeveloperExceptionPage();
      }

      app.UseRouting();

      app.UseEndpoints(endpoints => {
        endpoints.MapGrpcService<GrpcEndpointImpl>();
        ... More endpoints
      });
    }
}

public class GrpcEndpointImpl() {

    public GrpcEndpointImpl(ExampleService service) {
       ....
    }

}

我希望在启动应用程序后立即解析 ExampleService。我无法在文档中找到任何信息。我看了here and here。任何建议表示赞赏。

此致。

我最终在我的 Configure 方法中解决了 class' 依赖关系,如下所示:

public class Startup {

    ...

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
      if (env.IsDevelopment()) {
        app.UseDeveloperExceptionPage();
      }

      app.UseRouting();

      app.UseEndpoints(endpoints => {
        endpoints.MapGrpcService<GrpcEndpointImpl>();
        ... More endpoints
      });
      app.ApplicationServices.GetService<ExampleService>(); // Note this line here
    }
}

public class GrpcEndpointImpl() {

    public GrpcEndpointImpl(ExampleService service) {
       ....
    }

}