-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (42 loc) · 1.79 KB
/
Program.cs
File metadata and controls
48 lines (42 loc) · 1.79 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
namespace G2OSelfHost
{
using G2OAzureStorage;
using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Configuration;
using System.Diagnostics;
public class Program
{
static void Main(string[] args)
{
Console.Title = "G2O SelfHost";
Trace.Listeners.Clear();
Trace.Listeners.Add(new ConsoleTraceListener());
var listenUrl = "http://+:82/";
using (WebApp.Start<SelfhostStartup>(new StartOptions(listenUrl) { }))
{
Console.WriteLine("Server running on {0}", listenUrl);
Console.ReadLine();
}
}
}
public class SelfhostStartup
{
[Export("GetConfiguration")]
public Func<string, string> GetConfiguration { get { return _ => ConfigurationManager.AppSettings[_]; } }
public void Configuration(IAppBuilder app)
{
// A CompositionContainer object that can be accessed from multiple threads must set the isThreadSafe parameter to true.
// Performance will be slightly slower when isThreadSafe is true, so we recommend that you set this parameter to false in single-threaded scenarios. The default is false.
const bool willBeAccessedFromMultipleThreads = true;
var compositionContainer = new CompositionContainer(catalog: new AggregateCatalog(
new AssemblyCatalog(this.GetType().Assembly),
new AssemblyCatalog(typeof(G2OProxyConfiguration).Assembly)),
isThreadSafe: willBeAccessedFromMultipleThreads);
new MEFG2OProxyStartup().Configuration(app, compositionContainer);
}
}
}