55using Microsoft . AspNetCore . Mvc ;
66using Microsoft . Extensions . Configuration ;
77using Microsoft . Extensions . DependencyInjection ;
8+ using Microsoft . Extensions . Hosting ;
9+ using Microsoft . OpenApi . Models ;
810using SmartSql . InvokeSync . RabbitMQ ;
911using SmartSql . Sample . AspNetCore . Service ;
1012using Swashbuckle . AspNetCore . Swagger ;
@@ -24,7 +26,7 @@ public Startup(IConfiguration configuration)
2426 public IServiceProvider ConfigureServices ( IServiceCollection services )
2527 {
2628 // services.AddSkyApmExtensions().AddSmartSql();
27- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 ) ;
29+ services . AddControllers ( ) ;
2830 services
2931 . AddSmartSql ( ( sp , builder ) =>
3032 {
@@ -38,17 +40,17 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
3840 {
3941 o . AssemblyString = "SmartSql.Sample.AspNetCore" ;
4042 o . Filter = ( type ) => type . Namespace == "SmartSql.Sample.AspNetCore.DyRepositories" ;
41- } )
42- . AddInvokeSync ( options => { } )
43- . AddRabbitMQPublisher ( options =>
44- {
45- options . HostName = "localhost" ;
46- options . UserName = "guest" ;
47- options . Password = "guest" ;
48- options . Exchange = "smartsql" ;
49- options . RoutingKey = "smartsql.sync" ;
50-
5143 } ) ;
44+ // .AddInvokeSync(options => { })
45+ // .AddRabbitMQPublisher(options =>
46+ // {
47+ // options.HostName = "localhost";
48+ // options.UserName = "guest";
49+ // options.Password = "guest";
50+ // options.Exchange = "smartsql";
51+ // options.RoutingKey = "smartsql.sync";
52+ //
53+ // });
5254// .AddRabbitMQSubscriber(options =>
5355// {
5456// options.HostName = "localhost";
@@ -74,13 +76,13 @@ private void RegisterConfigureSwagger(IServiceCollection services)
7476 {
7577 services . AddSwaggerGen ( c =>
7678 {
77- c . SwaggerDoc ( "v1" , new Info
79+ c . SwaggerDoc ( "v1" , new OpenApiInfo ( )
7880 {
7981 Title = "SmartSql.Sample.AspNetCore" ,
8082 Version = "v1" ,
81- Contact = new Contact
83+ Contact = new OpenApiContact
8284 {
83- Url = "https://github.com/Smart-Kit/SmartSql" ,
85+ Url = new Uri ( "https://github.com/Smart-Kit/SmartSql" ) ,
84868587 Name = "SmartSql"
8688 } ,
@@ -91,23 +93,27 @@ private void RegisterConfigureSwagger(IServiceCollection services)
9193 }
9294
9395 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
94- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
96+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
9597 {
9698 if ( env . IsDevelopment ( ) )
9799 {
98100 app . UseDeveloperExceptionPage ( ) ;
99101 }
100102
101- app . ApplicationServices . UseSmartSqlSync ( ) ;
102- app . ApplicationServices . UseSmartSqlSubscriber ( ( syncRequest ) =>
103- {
104- Console . Error . WriteLine ( syncRequest . Scope ) ;
105- } ) ;
103+ // app.ApplicationServices.UseSmartSqlSync();
104+ // app.ApplicationServices.UseSmartSqlSubscriber((syncRequest) =>
105+ // {
106+ // Console.Error.WriteLine(syncRequest.Scope);
107+ // });
106108
107- app . UseMvc ( ) ;
108- app . UseStaticFiles ( ) ;
109109 app . UseSwagger ( c => { } ) ;
110110 app . UseSwaggerUI ( c => { c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "SmartSql.Sample.AspNetCore" ) ; } ) ;
111+
112+ app . UseRouting ( ) ;
113+ app . UseEndpoints ( endpoints =>
114+ {
115+ endpoints . MapControllers ( ) ;
116+ } ) ;
111117 }
112118 }
113119}
0 commit comments