-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.cs
80 lines (75 loc) · 3.24 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
// *************************************************************************************
// <copyright file="Startup.cs" company="Mobilize.Net">
// Copyright (c) 2018 Mobilize, Inc. All Rights Reserved,
// All classes are provided for customer use only,
// all other use is prohibited without prior written consent from Mobilize.Net,
// no warranty express or implied,
// use at own risk.
// </copyright>
// <summary></summary>
// *************************************************************************************
namespace WebSite
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.DependencyInjection;
using Mobilize.Web;
using Mobilize.WebMap.Common.Core;
using Mobilize.WebMap.Common.DCP;
using Mobilize.WebMap.Host;
using Mobilize.WebMap.Server;
using Mobilize.WebMap.Server.ObservableBinder;
/// <summary>
/// Startup
/// </summary>
public partial class Startup
{
/// <summary>
/// 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
/// </summary>
/// <param name="services">the collection of services</param>
public void ConfigureServices(IServiceCollection services)
{
services.AddWebMap();
services.RegisterModelMappers();
services.RegisterWrappers();
AddDesktopCompatibilityPlatform(services, Startup.Start);
services.AddDistributedMemoryCache();
services.AddSession();
services.AddAntiforgery(options => options.HeaderName = WebMapHeaders.AntiforgeryToken);
services.AddMvc(options =>
{
options.ModelBinderProviders.Insert(0, new ObservableModelBinderProvider());
options.ModelMetadataDetailsProviders.Insert(0, new SuppressChildValidationMetadataProvider(typeof(IObservable)));
});
}
/// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline
/// </summary>
/// <param name="app">the application builder</param>
/// <param name="env">the hosting environment</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseSession();
app.UseAntiforgeryToken();
app.UseWebMap();
app.UseMvc(routes =>
{
routes.MapRoute("DefaultApi", "api/{controller}/{id}");
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
}
private static void AddDesktopCompatibilityPlatform(IServiceCollection services, EntryPoint entryPoint)
{
services.AddSingleton<ICommandFactory, CommandFactory>();
services.AddScoped<IApplication>((provider) => new Application() { EntryPoint = entryPoint });
}
}
}