Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Startup.cs @ 17578

Last change on this file since 17578 was 13862, checked in by jlodewyc, 9 years ago

#2582 Start angular OKB manager, data loaded

File size: 3.4 KB
RevLine 
[13860]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using Microsoft.AspNetCore.Builder;
23using Microsoft.AspNetCore.Hosting;
[13656]24using Microsoft.Extensions.DependencyInjection;
25using HeuristicLab.Clients.Hive.WebJobManager.Services;
26using Microsoft.Extensions.Configuration;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
[13689]29using HeuristicLab.PluginInfrastructure;
[13739]30using System;
[13860]31using Microsoft.AspNetCore.Mvc.Razor;
32using System.Linq;
33using Microsoft.CodeAnalysis;
[13862]34using HeuristicLab.Clients.Hive.WebJobManager.Services.Imports;
[13656]35
36namespace HeuristicLab.Clients.Hive.WebJobManager
37{
38    public class Startup
39    {
[13689]40        public IHostingEnvironment hostingEnvironment {
41            get; set; }
[13656]42        public Startup(IHostingEnvironment hostingEnvironment)
43        {
44            var builder = new ConfigurationBuilder()
[13860]45                .SetBasePath(hostingEnvironment.ContentRootPath);
[13656]46            var config = builder.Build();
[13689]47
48            ApplicationManager.InitializeForWeb();
49
50
[13656]51            ContentManager.Initialize(new PersistenceContentManager());
52            //Console.WriteLine(""+ config.Get("configuration"));
53            this.hostingEnvironment = hostingEnvironment;
54        }
[13733]55         public void ConfigureServices(IServiceCollection services)
[13656]56        {
57
58            services.AddMvc();
[13739]59            services.AddSession(options => {
60                options.IdleTimeout = TimeSpan.FromMinutes(30);
61                options.CookieName = ".HiveWJM";
62            });
[13733]63            services.AddSingleton<IHiveServiceLocator, HiveServiceLocatorWeb>();
[13689]64            services.AddSignalR();
[13860]65            var myAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => MetadataReference.CreateFromFile(x.Location)).ToList();
66
67            services.Configure((RazorViewEngineOptions options) =>
68            {
69                var previous = options.CompilationCallback;
70                options.CompilationCallback = (context) =>
71                {
72                    previous?.Invoke(context);
73
74                    context.Compilation = context.Compilation.AddReferences(myAssemblies);
75                };
76            });
[13656]77        }
78
[13860]79      public void Configure(IApplicationBuilder app)
[13656]80        {
81            if (hostingEnvironment.IsDevelopment())
82                app.UseDeveloperExceptionPage();
[13860]83           
[13739]84            app.UseSession();
[13656]85            app.UseStaticFiles();
86            app.UseStatusCodePages();
[13689]87            app.UseMvcWithDefaultRoute();
[13860]88            app.UseSignalR();
[13656]89        }
90
[13689]91
92
[13656]93        // Entry point for the application.
[13860]94        //public static void Main(string[] args) => WebApplication.Run<Startup>(args);
[13656]95    }
96}
Note: See TracBrowser for help on using the repository browser.