|
@@ -1,22 +1,40 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using Grpc.Extension.Abstract;
|
|
|
|
+using Grpc.Extension.AspNetCore;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
+using TEAMModelOS.Grpc;
|
|
|
|
+using TEAMModelOS.GRPC.Services.Syllabus;
|
|
|
|
+using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
|
|
|
|
+using TEAMModelOS.SDK.Module.AzureCosmosDB.Configuration;
|
|
|
|
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
|
|
|
|
+using TEAMModelOS.SDK.Module.AzureTable.Implements;
|
|
|
|
+using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
|
|
|
|
|
|
namespace TEAMModelOS.Grpc
|
|
namespace TEAMModelOS.Grpc
|
|
{
|
|
{
|
|
public class Startup
|
|
public class Startup
|
|
{
|
|
{
|
|
|
|
+ private IConfiguration _conf;
|
|
|
|
+ public Startup(IConfiguration conf)
|
|
|
|
+ {
|
|
|
|
+ _conf = conf;
|
|
|
|
+ }
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
public void ConfigureServices(IServiceCollection services)
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
{
|
|
services.AddGrpc();
|
|
services.AddGrpc();
|
|
|
|
+ //添加Grpc扩展
|
|
|
|
+ services.AddGrpcExtensions(_conf);
|
|
}
|
|
}
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
@@ -32,12 +50,21 @@ namespace TEAMModelOS.Grpc
|
|
app.UseEndpoints(endpoints =>
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
{
|
|
endpoints.MapGrpcService<GreeterService>();
|
|
endpoints.MapGrpcService<GreeterService>();
|
|
-
|
|
|
|
|
|
+ endpoints.MapGrpcService<KnowledgeService>();
|
|
endpoints.MapGet("/", async context =>
|
|
endpoints.MapGet("/", async context =>
|
|
{
|
|
{
|
|
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
|
|
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ //CodeFirst的Grpc(会自动扫描TStartup所在程序集下的IGrpcService)
|
|
|
|
+ app.UseGrpcExtensions<KnowledgeService>(options =>
|
|
|
|
+ {
|
|
|
|
+ //CodeFirst配制
|
|
|
|
+ options.GlobalPackage = "TMDOSGRPC";
|
|
|
|
+ options.ProtoNameSpace = "TMDOSGRPC";
|
|
|
|
+ })
|
|
|
|
+ //CodeFirst生成proto
|
|
|
|
+ .UseProtoGenerate("Protos", false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|