Created
February 24, 2011 08:28
-
-
Save thecodejunkie/841923 to your computer and use it in GitHub Desktop.
Implementation of NancyModuleBuilder
This file contains hidden or 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
| public class DefaultNancyModuleBuilders : INancyModuleBuilder | |
| { | |
| private readonly INancyModuleCatalog moduleCatalog; | |
| private readonly IViewFactory viewFactory; | |
| private readonly ResponseFormatter responseFormatter; | |
| public DefaultNancyModuleBuilders(INancyModuleCatalog moduleCatalog, IViewFactory viewFactory, ResponseFormatter responseFormatter) | |
| { | |
| this.moduleCatalog = moduleCatalog; | |
| this.viewFactory = viewFactory; | |
| this.responseFormatter = responseFormatter; | |
| } | |
| /// <summary> | |
| /// Builds a fully configured <see cref="NancyModule"/> instance, based upon the provided <paramref name="moduleKey"/>. | |
| /// </summary> | |
| /// <param name="moduleKey">The key of the module to build.</param> | |
| /// <param name="context">The current request context.</param> | |
| /// <returns>A fully configured <see cref="NancyModule"/> instance.</returns> | |
| public NancyModule GetConfiguredModule(string moduleKey, NancyContext context) | |
| { | |
| var module = | |
| this.moduleCatalog.GetModuleByKey(moduleKey, context); | |
| module.Context = context; | |
| module.Response = this.responseFormatter; | |
| module.View = this.viewFactory; | |
| return module; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment