Last active
December 17, 2015 21:09
-
-
Save ianbattersby/5672963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Bazinga | |
{ | |
using System; | |
using System.ComponentModel.Composition; | |
using System.ComponentModel.Composition.Hosting; | |
using Fix; | |
using Microsoft.Owin.Hosting; | |
using Owin; | |
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>; | |
internal class Program | |
{ | |
public static readonly string Location = Path.GetDirectoryName(typeof(Simple.Web.Behaviors.IETag).Assembly.Location); | |
private static void Main(string[] args) | |
{ | |
var simpleWeb = BuildApp(); | |
var startOptions = new StartOptions("http://localhost:55000"); | |
using (WebApp.Start( | |
startOptions, | |
app => | |
{ | |
app.UseErrorPage(); | |
app.Use(new Func<AppFunc, AppFunc>(ignoreNextApp => (AppFunc)simpleWeb.Invoke)); | |
})) | |
{ | |
Console.WriteLine("Katana: listening at {0}. Press CTRL-C to stop.", hostname); | |
Console.ReadKey(); | |
} | |
} | |
private static AppFunc BuildApp() | |
{ | |
var fixer = new Fixer(); | |
using (var catalog = new AggregateCatalog()) | |
{ | |
catalog.Catalogs.Add(new AssemblyCatalog(typeof(Simple.Web.Behaviors.IETag).Assembly)); | |
var container = new CompositionContainer(catalog); | |
container.ComposeParts(fixer); | |
} | |
return fixer.BuildApp(); | |
} | |
} | |
public sealed class PathUtility : IPathUtility | |
{ | |
public string MapPath(string virtualPath) | |
{ | |
return Path.Combine(Program.Location, virtualPath.TrimStart('/').Replace('/', Path.DirectorySeparatorChar)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment