-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStartup.cs
111 lines (93 loc) · 3.77 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//using Microsoft.Bot.Builder;
//using Microsoft.Bot.Builder.Integration.AspNet.Core;
//using Microsoft.Bot.Schema;
using Microsoft.Graph.Communications.Common.Telemetry;
using Microsoft.OpenApi.Models;
using NotificationBot.Bot;
using NotificationBot.SpeechService;
using NotificationBot.ApiKey;
using System.Reflection;
using NotificationBot.Swagger;
//using System.Collections.Concurrent;
namespace NotificationBot
{
public class Startup
{
public IConfiguration _configuration;
private readonly GraphLogger _graphLogger;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
_graphLogger = new GraphLogger(typeof(Startup).Assembly.GetName().Name);
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddOptions();
services.AddRazorPages();
services.Configure<BotOptions>(_configuration.GetSection(BotOptions.Bot));
services.Configure<ToneOptions>(_configuration.GetSection(ToneOptions.Tone));
services.Configure<SpeechServiceOptions>(_configuration.GetSection(SpeechServiceOptions.Speech));
services.Configure<ApiKeyOption>(_configuration.GetSection(ApiKeyOption.ApiKey));
services.AddSingleton<IGraphLogger>(this._graphLogger);
// Message Bot Services
//services.AddTransient<CloudAdapter>();
//services.AddTransient<ConcurrentDictionary<string, ConversationReference>>();
services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Call Bot",
Description = "An ASP.NET Core Web API for calling users",
TermsOfService = new Uri("https://example.com/terms"),
Contact = new OpenApiContact
{
Name = "Example Contact",
Url = new Uri("https://example.com/contact")
},
License = new OpenApiLicense
{
Name = "Example License",
Url = new Uri("https://example.com/license")
}
}
);
var xmlFilename = Path.Combine(AppContext.BaseDirectory, "Lab.Swashbuckle.AspNetCore6.xml");
options.IncludeXmlComments(xmlFilename);
options.ParameterFilter<UtilityAudioParameterFilter>();
});
//services.AddTransient<IBot,MessageBot>();
services.AddSingleton<ICallBot, CallBot>();
//services.AddSingleton<INewClientBot, NewClientBot>();
services.AddEndpointsApiExplorer();
}
public void Configure(WebApplication app)
{
//if (app.Environment.IsDevelopment())
//{
// Allows swagger UI to be used for testing when publish profile is set to Debug
#if DEBUG
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Call Bot v1");
});
//}
#endif
app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.MapRazorPages();
app.Run();
}
}
}