-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
73 lines (63 loc) · 2.41 KB
/
Startup.cs
File metadata and controls
73 lines (63 loc) · 2.41 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Caching.Memory;
using FakeItEasy;
using NumericOverflow.Bot.Data;
using NumericOverflow.Bot.Services;
using NumericOverflow.Bot.Indexers.Data;
using NumericOverflow.Bot.Indexers.Services;
using NumericOverflow.Bot.Sample.Data;
using NumericOverflow.Bot.Sample.Services;
namespace NumericOverflow.Bot.Sample
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDataProtection();
services.AddAuthorization();
services.AddWebEncoders();
services.AddMemoryCache();
services.AddDotVVM(options =>
{
options.AddDefaultTempStorages("Temp");
this.AddCustomServices(options.Services);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
var dotvvmConfiguration = app.UseDotVVM<DotvvmStartup>(env.ContentRootPath);
app.UseStaticFiles();
//app.UseStaticFiles(new StaticFileOptions
//{
// FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(env.WebRootPath)
//});
}
private void AddCustomServices(IServiceCollection services)
{
services.AddTransient<IDialogStateRepository, MemoryCacheRepository>();
services.AddTransient<IDialogTextRepository, VoidDialogTextRepository>();
services.AddTransient<IRequestDispatcher, RequestDispatcher>();
services.AddTransient<IResolver, Resolver>();
services.AddSingleton<ITopicIndexer, TextSearchTopicIndexer>();
var jsonTopicRepository = new JsonTopicRepository(@".\PSTopics.json");
services.AddSingleton<ITopicRepository>(jsonTopicRepository);
var jsonTopicParameterRepository = new JsonTopicParameterRepository(@".\PSTopicParameters.json");
services.AddSingleton<ITopicParameterRepository>(jsonTopicParameterRepository);
this.AddBotServices(services);
}
private void AddBotServices(IServiceCollection services)
{
services.AddTransient<DateParameterBot, DateParameterBot>();
services.AddTransient<TopicBot, TopicBot>();
}
}
}