CR feedback
This commit is contained in:
parent
0ce2c511d4
commit
12985c19ee
|
|
@ -49,7 +49,6 @@ namespace MvcSample
|
||||||
new { controller = "Home" });
|
new { controller = "Home" });
|
||||||
|
|
||||||
builder.UseRouter(routes);
|
builder.UseRouter(routes);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,10 @@ namespace Microsoft.AspNet.Mvc
|
||||||
context.HttpContext.Response.ContentType = "text/html";
|
context.HttpContext.Response.ContentType = "text/html";
|
||||||
using (var writer = new StreamWriter(context.HttpContext.Response.Body, Encoding.UTF8, 1024, leaveOpen: true))
|
using (var writer = new StreamWriter(context.HttpContext.Response.Body, Encoding.UTF8, 1024, leaveOpen: true))
|
||||||
{
|
{
|
||||||
var viewContext = new ViewContext(context.HttpContext, ViewData, _serviceProvider);
|
var viewContext = new ViewContext(context.HttpContext, ViewData, _serviceProvider)
|
||||||
|
{
|
||||||
|
Url = new DefaultRenderUrl(context.HttpContext, context.Router, context.RouteValues),
|
||||||
|
};
|
||||||
await view.RenderAsync(viewContext, writer);
|
await view.RenderAsync(viewContext, writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +51,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
string locationsText = String.Join(Environment.NewLine, result.SearchedLocations);
|
string locationsText = String.Join(Environment.NewLine, result.SearchedLocations);
|
||||||
const string message = @"The view '{0}' was not found. The following locations were searched:{1}.";
|
const string message = @"The view '{0}' was not found. The following locations were searched:{1}.";
|
||||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, message, viewName, locationsText));
|
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, message, viewName, locationsText));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.View;
|
return result.View;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using Microsoft.AspNet.Abstractions;
|
using Microsoft.AspNet.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public virtual string Route(object values)
|
public virtual string Route(object values)
|
||||||
{
|
{
|
||||||
return RouteCore(new RouteValueDictionary(values));
|
return RouteCore(new RouteValueDictionary(values));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string RouteCore(IDictionary<string, object> values)
|
protected virtual string RouteCore(IDictionary<string, object> values)
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,22 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
{
|
{
|
||||||
public abstract class RazorView : IView
|
public abstract class RazorView : IView
|
||||||
{
|
{
|
||||||
public HttpContext Context { get; set; }
|
public ViewContext Context { get; set; }
|
||||||
|
|
||||||
public string Layout { get; set; }
|
public string Layout { get; set; }
|
||||||
|
|
||||||
protected TextWriter Output { get; set; }
|
protected TextWriter Output { get; set; }
|
||||||
|
|
||||||
public IRenderUrl Url { get; set; }
|
public IRenderUrl Url
|
||||||
|
{
|
||||||
|
get { return Context == null ? null : Context.Url; }
|
||||||
|
}
|
||||||
|
|
||||||
private string BodyContent { get; set; }
|
private string BodyContent { get; set; }
|
||||||
|
|
||||||
public virtual async Task RenderAsync(ViewContext context, TextWriter writer)
|
public virtual async Task RenderAsync(ViewContext context, TextWriter writer)
|
||||||
{
|
{
|
||||||
Url = context.RenderUrl;
|
Context = context;
|
||||||
|
|
||||||
var contentBuilder = new StringBuilder(1024);
|
var contentBuilder = new StringBuilder(1024);
|
||||||
using (var bodyWriter = new StringWriter(contentBuilder))
|
using (var bodyWriter = new StringWriter(contentBuilder))
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
|
|
||||||
public HtmlHelper<TModel> Html { get; set; }
|
public HtmlHelper<TModel> Html { get; set; }
|
||||||
|
|
||||||
public IRenderUrl RenderUrl { get; set; }
|
|
||||||
|
|
||||||
public override Task RenderAsync(ViewContext context, TextWriter writer)
|
public override Task RenderAsync(ViewContext context, TextWriter writer)
|
||||||
{
|
{
|
||||||
var viewData = context.ViewData as ViewData<TModel>;
|
var viewData = context.ViewData as ViewData<TModel>;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public interface IRenderUrl
|
public interface IRenderUrl
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,22 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public static class RenderUrlExtension
|
public static class RenderUrlExtension
|
||||||
{
|
{
|
||||||
public static string Action(this IRenderUrl generator)
|
public static string Action([NotNull] this IRenderUrl generator)
|
||||||
{
|
{
|
||||||
return generator.Action(null, null, null);
|
return generator.Action(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Action(this IRenderUrl generator, string action)
|
public static string Action([NotNull] this IRenderUrl generator, string action)
|
||||||
{
|
{
|
||||||
return generator.Action(action, null, null);
|
return generator.Action(action, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Action(this IRenderUrl generator, string action, object values)
|
public static string Action([NotNull] this IRenderUrl generator, string action, object values)
|
||||||
{
|
{
|
||||||
return generator.Action(action, null, values);
|
return generator.Action(action, null, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Action(this IRenderUrl generator, string action, string controller)
|
public static string Action([NotNull] this IRenderUrl generator, string action, string controller)
|
||||||
{
|
{
|
||||||
return generator.Action(action, controller, null);
|
return generator.Action(action, controller, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public IServiceProvider ServiceProvider { get; private set; }
|
public IServiceProvider ServiceProvider { get; private set; }
|
||||||
|
|
||||||
|
public IRenderUrl Url { get; set; }
|
||||||
|
|
||||||
public ViewData ViewData { get; private set; }
|
public ViewData ViewData { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue