Exemple #1
0
        private UnityContainer ConfigureUnity()
        {
            var packageLocator = new PackageLocator();

            // Explicitly load this assemblies packages first so that
            // these IoC mappings can be overriden by those found through
            // probing the bin folder assemblies
            packageLocator
            .Add(typeof(IConfigurationStore).Assembly)
            .Add(typeof(IRuleData).Assembly)
            .Add(Assembly.GetExecutingAssembly());

            // Probe the bin folder for any application specific implementations.
            // Note that in IocModules last one in wins, so probing the bin folder
            // after explicitly adding the Urchin assemblies allows integrators
            // to supply custom implementations of any interfaces registerd with IoC
            packageLocator
            .ProbeBinFolderAssemblies();

            // Construct and initialize a Unity container from the Ioc packages
            var unityContainer = new UnityContainer();

            unityContainer.RegisterInstance <IFactory>(new UnityFactory(unityContainer));
            Registrar.Register(packageLocator, unityContainer);

            return(unityContainer);
        }
Exemple #2
0
        public NinjectFactory()
        {
            var packageLocator = new PackageLocator().ProbeBinFolderAssemblies();

            _ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));
            _ninject.Rebind <IFactory>().ToConstant(this);
        }
Exemple #3
0
        public void Configuration(IAppBuilder app)
        {
            #region Configure the Owin pipeline

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample3/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample3/debugInfo");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Initialize the Pages middleware

            var fluentBuilder = ninject.Get <IFluentBuilder>();

            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);

            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            ninject.Get <INameManager>().Bind();

            #endregion
        }
Exemple #4
0
        public void Configuration(IAppBuilder app)
        {
            // This example shows how to use the Ninject IoC container to construct the
            // Owin pipeline buider. You can use any other IoC container supported by
            // the Ioc.Modules package with just one line of code change. You can also
            // choose not to use IoC, or configure any other IoC container you like.
            var packageLocator = new PackageLocator().ProbeAllLoadedAssemblies();
            var ninject        = new StandardKernel(new Module(packageLocator));
            var builder        = ninject.Get <IBuilder>();

            // This next part defines the concrete implementation of the various
            // OWIN middleware components you want to use in your application. The
            // order that these will be chained into the OWIN pipeline will be
            // determined from the dependencies defined within the components.

            // This is a simplified example, in a real application you should provide a
            // configuration mechanism. This example will run with all default
            // configuration values.

            builder.Register(ninject.Get <NotFoundError>());
            builder.Register(ninject.Get <PrintRequest>());
            builder.Register(ninject.Get <ReportExceptions>());
            builder.Register(ninject.Get <FormsIdentification>());
            builder.Register(ninject.Get <TemplatePageRendering>());
            builder.Register(ninject.Get <AllowEverythingAuthorization>());
            builder.Register(ninject.Get <InProcessSession>());

            // The next few lines build the Owin pipeline. Note that the
            // Owin Framework builder adds to the pipeline but other middleware
            // can also be added to the pipeline before or after it.

            app.UseErrorPage();
            app.UseBuilder(builder);
            app.UseWelcomePage("/");
        }
Exemple #5
0
        public void Configuration(IAppBuilder app)
        {
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            Factory.IocContainer = t => ninject.Get(t);

            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            var config = ninject.Get <IConfiguration>();

            var pipelineBuilder = ninject.Get <IBuilder>();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/gravity/middleware/pages");
            pipelineBuilder.Register(ninject.Get <ListenerMiddleware>()).ConfigureWith(config, "/gravity/middleware/listener");
#if DEBUG
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/gravity/middleware/debugInfo");
#endif

            app.UseBuilder(pipelineBuilder);

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Restful.BuildEngine>().Install(fluentBuilder);
            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            var nameManager = ninject.Get <INameManager>();
            nameManager.Bind();
        }
        public void Configuration(IAppBuilder app)
        {
            // These next two lines configure IocModules package to use Ninject as the IOC container
            var packageLocator = new PackageLocator().ProbeBinFolderAssemblies();
            var ninject        = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // Use this Ninject container as the Prius factory
            Package.PriusFactory.Ninject = ninject;

            // Tell urchin to get its configuration from the config.json file in this project. Note that if
            // you edit this file whilst the site is running the changes will be applied without
            // restarting the site.
            var configFile = new FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config.json");
            var configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Use the Owin Framework to build the OWIN pipeline
            BuildPipeline(app, ninject);

            // Register an OWIN app disposing handler that frees resources
            var properties = new AppProperties(app.Properties);
            var token      = properties.OnAppDisposing;

            token.Register(() =>
            {
                configurationFileSource.Dispose();
                ninject.Dispose();
            });
        }
Exemple #7
0
        private static UnityContainer ConfigureIoc()
        {
            var container = new UnityContainer();
            container.RegisterInstance(container);

            var packageLocator = new PackageLocator().ProbeBinFolderAssemblies().Add(Assembly.GetExecutingAssembly());
            Ioc.Modules.Unity.Registrar.Register(packageLocator, container);

            return container;
        }
        public void Configuration(IAppBuilder app)
        {
            // The package locator finds assemblies that advertise their IoC requirements
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            // For this example we will use Ninject as the IoC container
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // Prius requires a factory to work
            PriusIntegration.PriusFactory.Ninject = ninject;

            // Load up the configuration file and watch for changes
            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Get a reference to the loaded configuration
            var config = ninject.Get <IConfiguration>();

            // Get the Owin Framework pipeline builder
            var pipelineBuilder = ninject.Get <IBuilder>();

#if DEBUG
            pipelineBuilder.EnableTracing();
#endif

            // Add middleware defined by this application
            pipelineBuilder.Register(ninject.Get <RedirectMiddleware>()).ConfigureWith(config, "/middleware/redirect");

            // The Pages middleware provides html page rendering and REST services
            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/middleware/pages");

            // The Less middleware will dynamically compile less into css and cache in memory
            pipelineBuilder.Register(ninject.Get <OwinFramework.Less.LessMiddleware>()).ConfigureWith(config, "/middleware/less").As("Less");

            // The static files middleware will serve files from the file system to the browser
            pipelineBuilder.Register(ninject.Get <OwinFramework.StaticFiles.StaticFilesMiddleware>()).ConfigureWith(config, "/middleware/staticFiles/scripts").As("Scripts").RunAfter("Less");
            pipelineBuilder.Register(ninject.Get <OwinFramework.StaticFiles.StaticFilesMiddleware>()).ConfigureWith(config, "/middleware/staticFiles/images").As("Images").RunAfter("Less");

            // The Not Found middleware will return a friendly 404 page
            pipelineBuilder.Register(ninject.Get <OwinFramework.NotFound.NotFoundMiddleware>()).ConfigureWith(config, "/middleware/notFound");

            // The Exception Reporter middleware will catch exceptions in the Owin pipeline and report them
            pipelineBuilder.Register(ninject.Get <OwinFramework.ExceptionReporter.ExceptionReporterMiddleware>()).ConfigureWith(config, "/middleware/exceptions").RunFirst();

            // The Output Cache middleware will cache some assets in memory and also instruct the browser to cache certain assets
            pipelineBuilder.Register(ninject.Get <OwinFramework.OutputCache.OutputCacheMiddleware>()).ConfigureWith(config, "/middleware/outputCache");

            // The Versioning middleware will add a version number to assets allowing them to be cached by the browser indefinately
            pipelineBuilder.Register(ninject.Get <OwinFramework.Versioning.VersioningMiddleware>()).ConfigureWith(config, "/middleware/versioning");

# if USER_ACCOUNTS
Exemple #9
0
 public Program(UriCorrector uriCorrector, PackageLocator packageLocator, IFileSystem fileSystem,
                ProjectDependencyResolver projectDependencyResolver, LicenseDownloader licenseDownloader, IReporter reporter, IEntryPointLocator entryPointLocator)
 {
     _uriCorrector              = uriCorrector;
     _packageLocator            = packageLocator;
     _fileSystem                = fileSystem;
     _projectDependencyResolver = projectDependencyResolver;
     _downloader                = licenseDownloader;
     _reporter          = reporter;
     _entryPointLocator = entryPointLocator;
 }
        public void Configuration(IAppBuilder app)
        {
            #region Configure the Owin pipeline

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample3/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample3/debugInfo");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Initialize the Pages middleware

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            var requestRouter = ninject.Get <IRequestRouter>();
            var nameManager   = ninject.Get <INameManager>();

            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);

            fluentBuilder.Register(typeof(ApplicationPackage), t => ninject.Get(t));

            fluentBuilder.Register(typeof(Page1), t => ninject.Get(t));
            fluentBuilder.Register(typeof(Page1BodyComponent), t => ninject.Get(t));

            fluentBuilder.Register(typeof(Page2), t => ninject.Get(t));
            fluentBuilder.Register(typeof(Page2BodyLayout), t => ninject.Get(t));
            fluentBuilder.Register(typeof(Page2BodyRegion), t => ninject.Get(t));

            fluentBuilder.Register(typeof(BasePageLayout), t => ninject.Get(t));
            fluentBuilder.Register(typeof(HeaderRegion), t => ninject.Get(t));
            fluentBuilder.Register(typeof(BodyRegion), t => ninject.Get(t));
            fluentBuilder.Register(typeof(FooterRegion), t => ninject.Get(t));
            fluentBuilder.Register(typeof(HeaderComponent), t => ninject.Get(t));
            fluentBuilder.Register(typeof(FooterComponent), t => ninject.Get(t));
            fluentBuilder.Register(typeof(PersonComponent), t => ninject.Get(t));
            fluentBuilder.Register(typeof(AddressComponent), t => ninject.Get(t));

            fluentBuilder.Register(typeof(ApplicationInfoDataProvider), t => ninject.Get(t));
            fluentBuilder.Register(typeof(PersonListProvider), t => ninject.Get(t));
            fluentBuilder.Register(typeof(PersonAddressProvider), t => ninject.Get(t));

            nameManager.Bind();

            #endregion
        }
Exemple #11
0
        private static UnityContainer ConfigureIoc()
        {
            var container = new UnityContainer();

            container.RegisterInstance(container);

            var packageLocator = new PackageLocator().ProbeBinFolderAssemblies().Add(Assembly.GetExecutingAssembly());

            Ioc.Modules.Unity.Registrar.Register(packageLocator, container);

            return(container);
        }
        public void Configuration(IAppBuilder app)
        {
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var hostingEnvironment = ninject.Get <IHostingEnvironment>();

#if DEBUG
            var configFile = new FileInfo(hostingEnvironment.MapPath("config.debug.json"));
#else
            var configFile = new FileInfo(hostingEnvironment.MapPath("config.json"));
#endif
            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            var config = ninject.Get <IConfiguration>();

            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <ExceptionReporterMiddleware>()).ConfigureWith(config, "/middleware/exceptionReporter").RunFirst();
            pipelineBuilder.Register(ninject.Get <OutputCacheMiddleware>()).ConfigureWith(config, "/middleware/outputCache").As("OutputCache");
            pipelineBuilder.Register(ninject.Get <VersioningMiddleware>()).ConfigureWith(config, "/middleware/versioning").As("Versioning").RunAfter("OutputCache");
            pipelineBuilder.Register(ninject.Get <LessMiddleware>()).ConfigureWith(config, "/middleware/less").As("Less").RunAfter("Versioning");
            pipelineBuilder.Register(ninject.Get <StaticFilesMiddleware>()).ConfigureWith(config, "/middleware/staticFiles/assets").As("StaticFiles").RunAfter("Less");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/middleware/debugInfo").As("DebugInfo");
            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/middleware/pages").RunAfter("StaticFiles").RunAfter("DebugInfo");
            pipelineBuilder.Register(ninject.Get <NotFoundMiddleware>()).ConfigureWith(config, "/middleware/notFound").RunLast();

            app.UseBuilder(pipelineBuilder);

            var fluentBuilder = ninject.Get <IFluentBuilder>();

            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);

            fluentBuilder.RegisterPackage(ninject.Get <MenuPackage>(), "menu");
            fluentBuilder.RegisterPackage(ninject.Get <LayoutsPackage>(), "layouts");
            fluentBuilder.RegisterPackage(ninject.Get <TextEffectsPackage>(), "text");

            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            LoadTemplates(ninject);

            var nameManager = ninject.Get <INameManager>();
            nameManager.Bind();
        }
Exemple #13
0
        public void Configuration(IAppBuilder app)
        {
            #region Configure the Owin pipeline

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample3/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample3/debugInfo");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Initialize the Pages middleware

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            var nameManager   = ninject.Get <INameManager>();
            var requestRouter = ninject.Get <IRequestRouter>();

            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);

            fluentBuilder.Register(typeof(Page1), t => ninject.Get(t));
            fluentBuilder.Register(typeof(PageLayout), t => ninject.Get(t));
            fluentBuilder.Register(typeof(DivRegion), t => ninject.Get(t));
            fluentBuilder.Register(typeof(ApplicationPackage), t => ninject.Get(t));

            var uriLoader = ninject.Get <UriLoader>();
            var markdownTemplateParser = ninject.Get <MarkdownParser>();

            uriLoader.LoadUri(
                new Uri("https://raw.githubusercontent.com/Bikeman868/OwinFramework.Middleware/master/OwinFramework.FormIdentification/readme.md"),
                markdownTemplateParser,
                "/url/form-identification");

            nameManager.Bind();

            #endregion
        }
Exemple #14
0
        private UnityContainer ConfigureUnity()
        {
            var unityContainer = new UnityContainer();

            unityContainer.RegisterInstance <Shared.Interfaces.IFactory>(new UnityFactory(unityContainer));

            // Register IoC dependencies for all dependent packages.
            // Explicitly load this assemblies packages first so that
            // these IoC mappings override those found through probing
            var packageLocator = new PackageLocator()
                                 .Add(typeof(IConfigurationStore).Assembly)
                                 .Add(Assembly.GetExecutingAssembly())
                                 .ProbeBinFolderAssemblies();

            Ioc.Modules.Unity.Registrar.Register(packageLocator, unityContainer);

            return(unityContainer);
        }
Exemple #15
0
        public void Configuration(IAppBuilder app)
        {
            #region Configure Ninject as the IoC container

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            #endregion

            #region Build and Owin pipeline with only the Pages middleware in it

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample2/pages");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Choose which builders to use for layouts, regions, components and pages

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);

            #endregion

            #region Find all the layouts, regions, components and pages in my website

            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            #endregion

            #region Resolve all the name references and bind everything together

            var nameManager = ninject.Get <INameManager>();
            nameManager.Bind();

            #endregion
        }
Exemple #16
0
        public void Configuration(IAppBuilder app)
        {
            #region Configure the Owin pipeline

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample3/pages");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Initialize the Pages middleware

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            var requestRouter = ninject.Get <IRequestRouter>();
            var nameManager   = ninject.Get <INameManager>();

            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);

            // We would not normally register the classes individually like this,
            // but I want to keep the use cases separate and in this version the
            // fluent builder can not register types by namespace.

            fluentBuilder.Register(typeof(ApplicationPackage), t => ninject.Get(t));
            fluentBuilder.Register(typeof(GameConsole), t => ninject.Get(t));
            fluentBuilder.Register(typeof(Console), t => ninject.Get(t));
            fluentBuilder.Register(typeof(FullWidth), t => ninject.Get(t));
            fluentBuilder.Register(typeof(GameMap), t => ninject.Get(t));
            fluentBuilder.Register(typeof(GameDataProvider), t => ninject.Get(t));

            nameManager.Bind();

            #endregion
        }
        public void Configuration(IAppBuilder app)
        {
            #region Configure the Owin pipeline

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            var urchin = ninject.Get <IConfigurationStore>();
            urchin.UpdateConfiguration("{ 'owinFramework': { 'pages': { 'framework': { 'debugLogging': true } } } }");

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample3/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample3/debugInfo");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Initialize the Pages middleware

            var fluentBuilder           = ninject.Get <IFluentBuilder>();
            var nameManager             = ninject.Get <INameManager>();
            var templateBuilder         = ninject.Get <ITemplateBuilder>();
            var requestRouter           = ninject.Get <IRequestRouter>();
            Func <Type, object> factory = t => ninject.Get(t);

            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);

            fluentBuilder.Register(typeof(Page1), factory);
            fluentBuilder.Register(typeof(DivRegion), factory);
            fluentBuilder.Register(typeof(ApplicationPackage), factory);
            fluentBuilder.Register(typeof(BasePageLayout), factory);
            fluentBuilder.Register(typeof(ApplicationInfoDataProvider), factory);
            fluentBuilder.Register(typeof(PersonListProvider), factory);
            fluentBuilder.Register(typeof(PersonAddressProvider), factory);

            nameManager.Register(
                templateBuilder.BuildUpTemplate()
                .AddElementOpen("p", "class", "dummy")
                .AddText("this-is-the", "This is the ")
                .AddDataField <ApplicationInfo>(a => a.Name)
                .AddText("application", " application\n")
                .AddElementClose()
                .Build(),
                "/title");

            nameManager.Register(
                templateBuilder.BuildUpTemplate()
                .AddElementOpen("p")
                .AddDataField <Address>(p => p.Street).AddHtml("<br>")
                .AddDataField <Address>(p => p.City).AddHtml("<br>")
                .AddDataField <Address>(p => p.ZipCode)
                .AddElementClose()
                .Build(),
                "/address");

            nameManager.Register(
                templateBuilder.BuildUpTemplate()
                .AddElementOpen("h3")
                .AddDataField <Person>(p => p.Name)
                .AddElementClose()
                .ExtractProperty <Person>(p => p.Address)
                .AddTemplate("/address")
                .Build(),
                "/person");

            nameManager.Register(
                templateBuilder.BuildUpTemplate()
                .RepeatStart <Person>()
                .AddTemplate("/person")
                .RepeatEnd()
                .Build(),
                "/people");

            nameManager.Bind();

            #endregion
        }
Exemple #18
0
        public void Configuration(IAppBuilder app)
        {
            // The package locator finds assemblies that advertise their IoC requirements
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            // For this example we will use Ninject as the IoC container
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // Prius requires a factory to work
            PriusIntegration.PriusFactory.Ninject = ninject;

            // Next we load up the configuration file and watch for changes
            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Get a reference to the loaded configuration
            var config = ninject.Get <IConfiguration>();

            // Get the Owin Framework pipeline builder
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            // Define the middleware to add to the Owin Pipeline
            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample1/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample1/pages/debugInfo");
            pipelineBuilder.Register(ninject.Get <OwinFramework.NotFound.NotFoundMiddleware>()).ConfigureWith(config, "/sample1/notFound");
            pipelineBuilder.Register(ninject.Get <OwinFramework.Documenter.DocumenterMiddleware>()).ConfigureWith(config, "/sample1/documenter").RunFirst();
            pipelineBuilder.Register(ninject.Get <OwinFramework.DefaultDocument.DefaultDocumentMiddleware>()).ConfigureWith(config, "/sample1/defaultDocument");
            pipelineBuilder.Register(ninject.Get <OwinFramework.AnalysisReporter.AnalysisReporterMiddleware>()).ConfigureWith(config, "/sample1/analysisReporter");
            pipelineBuilder.Register(ninject.Get <OwinFramework.ExceptionReporter.ExceptionReporterMiddleware>()).RunFirst();

            // Build the owin pipeline
            app.UseBuilder(pipelineBuilder);

            // The IRequestRouter is the entry point to the Pages middleware
            var requestRouter = ninject.Get <IRequestRouter>();

            // The name manager allows elements that reference each other by name
            // to be registered in any order
            var nameManager = ninject.Get <INameManager>();

            // The Fluent Builder provides a mechanism for building elements (pages,
            // regions, layouts, components, data providers etc) without writing code
            // that implements the various interfaces like IPage, IComponent etc
            var fluentBuilder = ninject.Get <IFluentBuilder>();

            // This is an example of registering an implementation of IPage with a
            // wildcard request filter and below normal priority
            requestRouter.Register(
                new FullCustomPage(),
                new FilterAllFilters(
                    new FilterByMethod(Method.Head, Method.Get),
                    new FilterByPath("/pages/*.html")),
                -10);

            // This is an example of routing requests to a class that inherits from the
            // base Page class with an exact match request filter and higher than normal
            // priority
            requestRouter.Register(
                ninject.Get <SemiCustomPage>(),
                new FilterAllFilters(
                    new FilterByMethod(Method.Get, Method.Post, Method.Put),
                    new FilterByPath("/pages/semiCustom.html")),
                100);

            // You must install build engines before trying to build elements using the
            // fluent builder. You can use the built-in engines, install NuGet packages
            // that provide build engines, or write your own.
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Restful.BuildEngine>().Install(fluentBuilder);

            // This is an example of registering packages containing components, layouts etc
            // that can be referenced by name from other elements.
            // When you register a package like this all of the element in the package are
            // contained in a namespace to avoid naming conflicts. The namespace will be used
            // as a prefix on all css class names and JavaScript function names.
            // The package namespace can also be used to reference the elements within the
            // package by putting the namespace name and a colon in front of the element
            // name. For example after loading the menu package into the "menus" namespace
            // your application can refer to the desktop menu region as "menus:desktop_menu"
            fluentBuilder.RegisterPackage(ninject.Get <MenuPackage>(), "menus");
            fluentBuilder.RegisterPackage(ninject.Get <LayoutsPackage>(), "layouts");
            fluentBuilder.RegisterPackage(ninject.Get <LibrariesPackage>(), "libraries");
            fluentBuilder.RegisterPackage(ninject.Get <CmsStaticRuntimePackage>(), "cms");

            // This is an example of registering all of the elements defined in an assembly
            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            // This is an example of building and registering a custom template
            var templateBuilder = ninject.Get <ITemplateBuilder>();

            var template1 = templateBuilder.BuildUpTemplate()
                            .AddElementOpen("p", "class", "dummy")
                            .AddText("this-is-the", "This is the ")
                            .AddDataField <ApplicationInfo>(a => a.Name)
                            .AddText("application", " application")
                            .AddElementClose()
                            .Build();

            nameManager.Register(template1, "/common/pageTitle");

            var template2 = templateBuilder.BuildUpTemplate()
                            .AddHtml("alert('Hello!');")
                            .Build();

            nameManager.Register(template2, "/common/pageInitialization");

            var template3 = templateBuilder.BuildUpTemplate()
                            .AddElementOpen("p", "class", "test")
                            .AddText("page-2-body", "Page 2 body")
                            .AddElementClose()
                            .Build();

            nameManager.Register(template3, "/page2/body");

            // This is an example of loading and parsing template files using different
            // parsers for different file formats
            var asIsTemplateParser     = ninject.Get <AsIsParser>();
            var markdownTemplateParser = ninject.Get <MarkdownParser>();
            var mustacheParser         = ninject.Get <MustacheParser>();
            var multiPartParser        = ninject.Get <MultiPartParser>();

            // This is an example of loading and parsing template files using different
            // parsers for different file formats
            var fileSystemLoader = ninject.Get <FileSystemLoader>();

            fileSystemLoader.RootPath       = new PathString("/file");
            fileSystemLoader.ReloadInterval = TimeSpan.FromSeconds(3);
            fileSystemLoader.Load(asIsTemplateParser, p => p.Value.EndsWith(".html") || p.Value.EndsWith(".js") || p.Value.EndsWith(".css"));
            fileSystemLoader.Load(markdownTemplateParser, p => p.Value.EndsWith(".md"));
            fileSystemLoader.Load(mustacheParser, p => p.Value.EndsWith(".svg"));
            fileSystemLoader.Load(multiPartParser, p => p.Value.EndsWith(".vue"));

            // This is an example of loading and parsing template from a URL
            var uriLoader = ninject.Get <UriLoader>();

            uriLoader.LoadUri(new Uri("https://raw.githubusercontent.com/Bikeman868/OwinFramework.Middleware/master/OwinFramework.FormIdentification/readme.md"), markdownTemplateParser, "/url/template1");

            // Now that all of the elements are loaded an registered we can resolve name
            // references between elements
            nameManager.Bind();
        }
Exemple #19
0
        public void Configuration(IAppBuilder app)
        {
            // The package locator finds assemblies that advertise their IoC requirements
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            // For this example we will use Ninject as the IoC container
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // Next we load up the configuration file and watch for changes
            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Get a reference to the loaded configuration
            var config = ninject.Get <IConfiguration>();

            // Get the Owin Framework pipeline builder
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            // Define the middleware to add to the Owin Pipeline
            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample1/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample1/pages/debugInfo");
            pipelineBuilder.Register(ninject.Get <OwinFramework.NotFound.NotFoundMiddleware>()).ConfigureWith(config, "/sample1/notFound");
            pipelineBuilder.Register(ninject.Get <OwinFramework.Documenter.DocumenterMiddleware>()).ConfigureWith(config, "/sample1/documenter").RunFirst();
            pipelineBuilder.Register(ninject.Get <OwinFramework.DefaultDocument.DefaultDocumentMiddleware>()).ConfigureWith(config, "/sample1/defaultDocument");
            pipelineBuilder.Register(ninject.Get <OwinFramework.ExceptionReporter.ExceptionReporterMiddleware>()).RunFirst();

            // Build the owin pipeline
            app.UseBuilder(pipelineBuilder);

            // The IRequestRouter is the entry point to the Pages middleware
            var pageRequestRouter = ninject.Get <IRequestRouter>();

            // This is an example of registering an implementation of IPage with a
            // wildcard request filter and below normal priority
            pageRequestRouter.Register(
                new FullCustomPage(),
                new FilterAllFilters(
                    new FilterByMethod(Methods.Head, Methods.Get),
                    new FilterByPath("/pages/*.html")),
                -10);

            // This is an example of routing requests to a class that inherits from the
            // base Page class with an exact match request filter and higher than normal
            // priority
            pageRequestRouter.Register(
                ninject.Get <SemiCustomPage>(),
                new FilterAllFilters(
                    new FilterByMethod(Methods.Get, Methods.Post, Methods.Put),
                    new FilterByPath("/pages/semiCustom.html")),
                100);

            // The IFluentBuilder provides a mechanism for building elements (pages,
            // regions, layouts, components, data providers etc) without writing code
            // that implements the various interfaces like IPage, IComponent etc
            var fluentBuilder = ninject.Get <IFluentBuilder>();

            // You must install build engines before trying to build elements using the
            // fluent builder. You can use the built-in engines, install NuGet packages
            // that provide build engines, or write your own.
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Restful.BuildEngine>().Install(fluentBuilder);

            // This is an example of registering a package containing components, layouts etc
            // that can be referenced by name from other elements.
            // When you register a package like this all of the element in the package are
            // contained in a namespace to avoid naming conflicts. The namespace will be used
            // as a prefix on all css class names and JavaScript function names.
            // The package namespace can also be used to reference the elements within the
            // package by putting the namespace name and a colon in front of the element
            // name. For example after loading the menu package into the "menus" namespace
            // your application can refer to the desktop menu region as "menus:desktop_menu"
            fluentBuilder.Register(ninject.Get <MenuPackage>(), "menus");

            // This is an example of registering all of the elements defined in an assembly
            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            // Now that all of the elements are loaded an registered we can resolve name
            // references between elements
            var nameManager = ninject.Get <INameManager>();

            nameManager.Bind();
        }
        public void Configuration(IAppBuilder app)
        {
            #region Configure Ninject as the IoC container

            // You can use any IoC container you like. In this example I am using Ninject

            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            #endregion

            #region Build an Owin pipeline with only the Pages middleware in it

            // To keep this example easy to understand I am only adding the Pages middleware
            // to the OWIN pipeline. In your application you will likely want to add other
            // middleware here - static files, identification and authorization etc

            var config          = ninject.Get <IConfiguration>();
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing(RequestsToTrace.QueryString);

            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample2/pages");
            app.UseBuilder(pipelineBuilder);

            #endregion

            #region Choose which builders to use

            // The fluent builder has a plug in architecture. You can plug in builders for
            // layouts, regions, components, pages, data providers, services, modules and packages
            // The OwinFramework.Pages.Html.BuildEngine contains builders for layouts, regions, components and pages

            var fluentBuilder = ninject.Get <IFluentBuilder>();
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);

            #endregion

            #region Find all the layouts, regions, components and pages in my website

            // You can register your layouts, regions, pages etc individually, or
            // you can ask the fluent builder to scan assemblies for classes that
            // are decorated with attributes that identify them as these element types.

            // Note that passing a factory method here allows your layouts, regions, pages etc
            // to use constructor injection. If you do not pass a factory method there then
            // these classes must have a default public constructor.

            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            #endregion

            #region Resolve all the name references and bind everything together

            // When the fluent builder registered all of your regions, layouts etc
            // they were all added to the Name Manager in random order. If these
            // elements refer to each other by name then these name references must
            // be resolved after all of the elements are registered

            ninject.Get <INameManager>().Bind();

            #endregion
        }
Exemple #21
0
        public void Configuration(IAppBuilder app)
        {
            // The package locator finds assemblies that advertise their IoC requirements
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            // For this example we will use Ninject as the IoC container
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // Prius requires a factory to work
            PriusIntegration.PriusFactory.Ninject = ninject;

            // Next we load up the configuration file and watch for changes
            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Get a reference to the loaded configuration
            var config = ninject.Get <IConfiguration>();

            // Get the Owin Framework pipeline builder
            var pipelineBuilder = ninject.Get <IBuilder>().EnableTracing();

            // Define the middleware to add to the Owin Pipeline
            pipelineBuilder.Register(ninject.Get <PagesMiddleware>()).ConfigureWith(config, "/sample4/pages");
            pipelineBuilder.Register(ninject.Get <DebugInfoMiddleware>()).ConfigureWith(config, "/sample4/pages/debugInfo");
            pipelineBuilder.Register(ninject.Get <OwinFramework.NotFound.NotFoundMiddleware>()).ConfigureWith(config, "/sample4/notFound");
            pipelineBuilder.Register(ninject.Get <OwinFramework.DefaultDocument.DefaultDocumentMiddleware>()).ConfigureWith(config, "/sample4/defaultDocument");
            pipelineBuilder.Register(ninject.Get <OwinFramework.ExceptionReporter.ExceptionReporterMiddleware>()).RunFirst();

            // Build the owin pipeline
            app.UseBuilder(pipelineBuilder);

            // The name manager allows elements that reference each other by name
            // to be registered in any order
            var nameManager = ninject.Get <INameManager>();

            // The Fluent Builder provides a mechanism for building elements (pages,
            // regions, layouts, components, data providers etc) without writing code
            // that implements the various interfaces like IPage, IComponent etc
            var fluentBuilder = ninject.Get <IFluentBuilder>();

            // If you want to use dependency injection with your elements then you will need
            // to define a factory method so that the fluent builder can construct the classes
            // that it finds in your assemblies.
            Func <Type, object> factory = t => ninject.Get(t);

            // You must install build engines before trying to build elements using the
            // fluent builder. You can use the built-in engines, install NuGet packages
            // that provide build engines, or write your own.
            ninject.Get <OwinFramework.Pages.Framework.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Html.BuildEngine>().Install(fluentBuilder);
            ninject.Get <OwinFramework.Pages.Restful.BuildEngine>().Install(fluentBuilder);

            // This is an example of registering packages containing components, layouts etc
            // that can be referenced by name from other elements.
            // When you register a package like this all of the element in the package are
            // contained in a namespace to avoid naming conflicts. The namespace will be used
            // as a prefix on all css class names and JavaScript function names.
            // The package namespace can also be used to reference the elements within the
            // package by putting the namespace name and a colon in front of the element
            // name. For example after loading the menu package into the "menus" namespace
            // your application can refer to the desktop menu region as "menus:desktop_menu"
            // Packages also have a default namespace to use if you don't specify one in
            // your application code.
            fluentBuilder.RegisterPackage(ninject.Get <MenuPackage>(), "menus", factory);
            fluentBuilder.RegisterPackage(ninject.Get <LayoutsPackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <LibrariesPackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <TemplatesPackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <AjaxPackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <DataPackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <CmsStaticRuntimePackage>(), factory);
            fluentBuilder.RegisterPackage(ninject.Get <CmsManagerPackage>(), factory);

            // Register all of the elements defined in this assembly
            fluentBuilder.Register(Assembly.GetExecutingAssembly(), t => ninject.Get(t));

            // This is an example of loading and parsing template files using the same
            // parser for all templates. In this case they are html files with server-side
            // data binding expressions using the mustache format.
            var mustacheParser   = ninject.Get <MustacheParser>();
            var fileSystemLoader = ninject.Get <FileSystemLoader>();

            fileSystemLoader.ReloadInterval = TimeSpan.FromSeconds(3);
            fileSystemLoader.Load(mustacheParser, p => p.Value.EndsWith(".html"));

            // Now that all of the elements are loaded an registered we can resolve name
            // references between elements binding them together into a runable website
            nameManager.Bind();
        }
        public void Configuration(IAppBuilder app)
        {
            // By explicitly adding this assembly to the package locator, any IoC mappings
            // in this assembly will take priority over assemblies found through probing.
            // Also when the package locator probes for assemblies it only looks for DLLs
            // and not executables.
            var packageLocator = new PackageLocator()
                                 .ProbeBinFolderAssemblies()
                                 .Add(Assembly.GetExecutingAssembly());

            // Construct the Ninject IoC container and configure it using information from
            // the package locator
            var ninject = new StandardKernel(new Ioc.Modules.Ninject.Module(packageLocator));

            // The prius factory needs Ninject to resolve interfaces to concrete types
            PriusFactory.Ninject = ninject;

            // Tell urchin to get its configuration from the config.json file in this project. Note that if
            // you edit this file whilst the application is running the changes will be applied without
            // restarting the application.
            var hostingEnvironment = ninject.Get <IHostingEnvironment>();
            var configFile         = new FileInfo(hostingEnvironment.MapPath("config.json"));

            _configurationFileSource = ninject.Get <FileSource>().Initialize(configFile, TimeSpan.FromSeconds(5));

            // Construct the configuration mechanism that is registered with IoC (Urchin)
            var config = ninject.Get <IConfiguration>();

            // Get the Owin Framework builder registered with IoC
            var builder = ninject.Get <IBuilder>().EnableTracing();

            // Output caching just makes the web site more efficient by capturing the output from
            // downstream middleware and reusing it for the next request. Note that the Dart middleware
            // produces different results for the same URL and therefore can not use output caching
            builder.Register(ninject.Get <OutputCache.OutputCacheMiddleware>())
            .As("Output cache")
            .ConfigureWith(config, "/middleware/outputCache")
            .RunAfter("Dart");

            // The Versioning middleware will add version numbers to static assets and
            // instruct the browser to cache them
            builder.Register(ninject.Get <Versioning.VersioningMiddleware>())
            .As("Versioning")
            .ConfigureWith(config, "/middleware/versioning")
            .RunAfter <IOutputCache>();

            // The dart middleware will allow the example Dart UI to run in browsers that support Dart
            // natively as well as supplying compiled JavaScript to browsers that dont support Dart natively.
            builder.Register(ninject.Get <Dart.DartMiddleware>())
            .As("Dart")
            .ConfigureWith(config, "/middleware/dart");

            // The Less middleware will compile LESS into CSS on the fly
            builder.Register(ninject.Get <Less.LessMiddleware>())
            .As("LESS compiler")
            .ConfigureWith(config, "/middleware/less")
            .RunAfter("Dart");

            // The static files middleware will allow requests to retrieve files of certian types
            // Configuration options limit the files that can be retrieved this way. The ConfigureWith
            // fluid method below specifies the location of this configuration in the config.json file
            builder.Register(ninject.Get <StaticFiles.StaticFilesMiddleware>())
            .As("Static files")
            .ConfigureWith(config, "/middleware/staticFiles")
            .RunAfter("LESS compiler")
            .RunAfter("Dart");

            // The form identification middleware provides login/logout password reset etc
            builder.Register(ninject.Get <FormIdentification.FormIdentificationMiddleware>())
            .As("Form Identification")
            .ConfigureWith(config, "/middleware/formIdentification")
            .RunAfter("Static files");

            // This middleware prints information about the logged on user to the console
            // for testing and debugging purposes
            builder.Register(ninject.Get <LogUserInfoMiddleware>())
            .As("Log user info");

            // The cache session middleware provides session management using the cache facility
            builder.Register(ninject.Get <Session.CacheSessionMiddleware>())
            .As("Cache session")
            .ConfigureWith(config, "/middleware/session")
            .RunAfter("Static files");

            // The route visualizer middleware will produce an SVG showing the Owin pipeline configuration
            builder.Register(ninject.Get <RouteVisualizer.RouteVisualizerMiddleware>())
            .As("Route visualizer")
            .ConfigureWith(config, "/middleware/visualizer")
            .RunAfter <IIdentification>();

            // The default document middleware will rewrite a request for the root document to a page on the site
            builder.Register(ninject.Get <DefaultDocument.DefaultDocumentMiddleware>())
            .As("Default document")
            .ConfigureWith(config, "/middleware/defaultDocument");

            // The not found middleware will always return a 404 response. Configure it to run after all
            // other middleware to catch requests that no other middleware handled
            builder.Register(ninject.Get <NotFound.NotFoundMiddleware>())
            .As("Not found")
            .ConfigureWith(config, "/middleware/notFound")
            .RunLast();

            // The analysis reporter middleware will format analytics from middleware that supports
            // this feature. The middleware can produce reports in various formats including
            // HTML, plain text and JSON. Analytics are things like the number of requests processed
            // per second and the average time taken to handle a request.
            builder.Register(ninject.Get <AnalysisReporter.AnalysisReporterMiddleware>())
            .As("Analysis reporter")
            .ConfigureWith(config, "/middleware/analysis")
            .RunAfter <IIdentification>();

            // The documenter middleware will extract documentation from middleware that is
            // self documenting. If your web site is an API this is a more convenient way of
            // documenting the API than maintaining separate documentation, and the documentation
            // is always applicable to the specific version you are calling.
            builder.Register(ninject.Get <Documenter.DocumenterMiddleware>())
            .As("Documenter")
            .ConfigureWith(config, "/middleware/documenter")
            .RunAfter <IIdentification>();

            // The exception reporter middleware will catch exceptions and produce diagnostic output
            builder.Register(ninject.Get <ExceptionReporter.ExceptionReporterMiddleware>())
            .As("Exception reporter")
            .ConfigureWith(config, "/middleware/exceptions")
            .RunFirst();

            // The exception generator middleware will throw exceptions so that you can test the handler
            builder.Register(ninject.Get <ExceptionReporter.ExceptionGeneratorMiddleware>())
            .As("Exception generator")
            .RunLast();

            // Use the Owin Framework builder to add middleware to the Owin pipeline
            app.UseBuilder(builder);
        }