5
5
using Microsoft . AspNetCore . Mvc ;
6
6
using Microsoft . Extensions . Configuration ;
7
7
using Microsoft . Extensions . DependencyInjection ;
8
+ using Microsoft . Extensions . Hosting ;
9
+ using Microsoft . OpenApi . Models ;
8
10
using SmartSql . InvokeSync . RabbitMQ ;
9
11
using SmartSql . Sample . AspNetCore . Service ;
10
12
using Swashbuckle . AspNetCore . Swagger ;
@@ -24,7 +26,7 @@ public Startup(IConfiguration configuration)
24
26
public IServiceProvider ConfigureServices ( IServiceCollection services )
25
27
{
26
28
// services.AddSkyApmExtensions().AddSmartSql();
27
- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 ) ;
29
+ services . AddControllers ( ) ;
28
30
services
29
31
. AddSmartSql ( ( sp , builder ) =>
30
32
{
@@ -38,17 +40,17 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
38
40
{
39
41
o . AssemblyString = "SmartSql.Sample.AspNetCore" ;
40
42
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
-
51
43
} ) ;
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
+ // });
52
54
// .AddRabbitMQSubscriber(options =>
53
55
// {
54
56
// options.HostName = "localhost";
@@ -74,13 +76,13 @@ private void RegisterConfigureSwagger(IServiceCollection services)
74
76
{
75
77
services . AddSwaggerGen ( c =>
76
78
{
77
- c . SwaggerDoc ( "v1" , new Info
79
+ c . SwaggerDoc ( "v1" , new OpenApiInfo ( )
78
80
{
79
81
Title = "SmartSql.Sample.AspNetCore" ,
80
82
Version = "v1" ,
81
- Contact = new Contact
83
+ Contact = new OpenApiContact
82
84
{
83
- Url = "https://github.com/Smart-Kit/SmartSql" ,
85
+ Url = new Uri ( "https://github.com/Smart-Kit/SmartSql" ) ,
84
86
85
87
Name = "SmartSql"
86
88
} ,
@@ -91,23 +93,27 @@ private void RegisterConfigureSwagger(IServiceCollection services)
91
93
}
92
94
93
95
// 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 )
95
97
{
96
98
if ( env . IsDevelopment ( ) )
97
99
{
98
100
app . UseDeveloperExceptionPage ( ) ;
99
101
}
100
102
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
+ // });
106
108
107
- app . UseMvc ( ) ;
108
- app . UseStaticFiles ( ) ;
109
109
app . UseSwagger ( c => { } ) ;
110
110
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
+ } ) ;
111
117
}
112
118
}
113
119
}
0 commit comments