Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jchannon
Forked from grumpydev/TestRenderContextFactory.cs
Last active December 10, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchannon/4494412 to your computer and use it in GitHub Desktop.
Save jchannon/4494412 to your computer and use it in GitHub Desktop.
protected override NancyInternalConfiguration InternalConfiguration
{
get
{
return
NancyInternalConfiguration.WithOverrides(x => x.RenderContextFactory = typeof (TestRenderContextFactory));
}
}
public class TestRenderContextFactory : IRenderContextFactory
{
private IViewResolver viewResolver;
private IViewCache viewCache;
public TestRenderContextFactory(IViewResolver viewResolver, IViewCache viewCache)
{
this.viewResolver = viewResolver;
this.viewCache = viewCache;
}
public IRenderContext GetRenderContext(ViewLocationContext viewLocationContext)
{
return new DefaultRenderContext(
this.viewResolver,
viewLocationContext.Context.Items.ContainsKey("DebugViewCache") ?
viewLocationContext.Context.Items["DebugViewCache"] as IViewCache :
this.viewCache,
viewLocationContext);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment