NancyFx/Nancy — pull request #856 by prabirshrestha (2012-12-10 03:36:49+00:00)
Title: added ViewFactoryExtensions

added `RenderView` extension method for `IViewFactory`.

Usage:

```c#
public class Generic404ErrorHandler : IErrorHandler
{
private readonly IViewFactory factory;
private readonly IViewLocationCache cache;

public Generic404ErrorHandler(IViewFactory factory, IViewLocationCache cache)
{
this.factory = factory;
this.cache = cache;
}

public bool HandlesStatusCode(HttpStatusCode statusCode, NancyContext context)
{
return statusCode == HttpStatusCode.NotFound;
}

public void Handle(HttpStatusCode statusCode, NancyContext context)
{
var response = this.factory.RenderView(this.cache, context, "views/errors/404.cshtml");

// RenderView sets the context.Response.StatusCode to HttpStatusCode.OK
// so make sure to override it correctly
response.StatusCode = HttpStatusCode.NotFound;
}
}
```