CR feedback
This commit is contained in:
parent
12985c19ee
commit
77a7bb58a6
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
var viewContext = new ViewContext(context.HttpContext, ViewData, _serviceProvider)
|
||||
{
|
||||
Url = new DefaultRenderUrl(context.HttpContext, context.Router, context.RouteValues),
|
||||
Url = new DefaultUrlHelper(context.HttpContext, context.Router, context.RouteValues),
|
||||
};
|
||||
await view.RenderAsync(viewContext, writer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
public HttpContext Context { get; set; }
|
||||
|
||||
public IRenderUrl Url { get; set; }
|
||||
public IUrlHelper Url { get; set; }
|
||||
|
||||
public ViewData<object> ViewData { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,13 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
Action = action,
|
||||
};
|
||||
var actionContext = new ActionContext(context.HttpContext, null, context.RouteValues, action);
|
||||
|
||||
// Issues #60 & #65 filed to deal with the ugliness of passing null here.
|
||||
var actionContext = new ActionContext(
|
||||
httpContext: context.HttpContext,
|
||||
router: null,
|
||||
routeValues: context.RouteValues,
|
||||
actionDescriptor: action);
|
||||
var actionBindingContext = await _bindingProvider.GetActionBindingContextAsync(actionContext);
|
||||
|
||||
foreach (var parameter in action.Parameters.Where(p => p.ParameterBindingInfo != null))
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
prop.SetValue(controller, modelState);
|
||||
}
|
||||
else if (prop.Name == "Url" && prop.PropertyType == typeof(IRenderUrl))
|
||||
else if (prop.Name == "Url" && prop.PropertyType == typeof(IUrlHelper))
|
||||
{
|
||||
var generator = new DefaultRenderUrl(
|
||||
var generator = new DefaultUrlHelper(
|
||||
actionContext.HttpContext,
|
||||
actionContext.Router,
|
||||
actionContext.RouteValues);
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@ using Microsoft.AspNet.Routing;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public class DefaultRenderUrl : IRenderUrl
|
||||
public class DefaultUrlHelper : IUrlHelper
|
||||
{
|
||||
private readonly HttpContext _httpContext;
|
||||
private readonly IRouter _router;
|
||||
private readonly IDictionary<string, object> _ambientValues;
|
||||
|
||||
public DefaultRenderUrl(HttpContext httpContext, IRouter router, IDictionary<string, object> ambientValues)
|
||||
public DefaultUrlHelper(HttpContext httpContext, IRouter router, IDictionary<string, object> ambientValues)
|
||||
{
|
||||
_httpContext = httpContext;
|
||||
_router = router;
|
||||
_ambientValues = ambientValues;
|
||||
}
|
||||
|
||||
public virtual string Action(string action, string controller, object values)
|
||||
public string Action(string action, string controller, object values)
|
||||
{
|
||||
var valuesDictionary = new RouteValueDictionary(values);
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ namespace Microsoft.AspNet.Mvc
|
|||
return RouteCore(valuesDictionary);
|
||||
}
|
||||
|
||||
public virtual string Route(object values)
|
||||
public string Route(object values)
|
||||
{
|
||||
return RouteCore(new RouteValueDictionary(values));
|
||||
}
|
||||
|
||||
protected virtual string RouteCore(IDictionary<string, object> values)
|
||||
private string RouteCore(IDictionary<string, object> values)
|
||||
{
|
||||
var context = new VirtualPathContext(_httpContext, _ambientValues, values);
|
||||
var path = _router.GetVirtualPath(context);
|
||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
|
||||
protected TextWriter Output { get; set; }
|
||||
|
||||
public IRenderUrl Url
|
||||
public IUrlHelper Url
|
||||
{
|
||||
get { return Context == null ? null : Context.Url; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public interface IRenderUrl
|
||||
public interface IUrlHelper
|
||||
{
|
||||
string Action(string action, string controller, object values);
|
||||
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public static class RenderUrlExtension
|
||||
public static class UrlHelperExtensions
|
||||
{
|
||||
public static string Action([NotNull] this IRenderUrl generator)
|
||||
public static string Action([NotNull] this IUrlHelper generator)
|
||||
{
|
||||
return generator.Action(null, null, null);
|
||||
}
|
||||
|
||||
public static string Action([NotNull] this IRenderUrl generator, string action)
|
||||
public static string Action([NotNull] this IUrlHelper generator, string action)
|
||||
{
|
||||
return generator.Action(action, null, null);
|
||||
}
|
||||
|
||||
public static string Action([NotNull] this IRenderUrl generator, string action, object values)
|
||||
public static string Action([NotNull] this IUrlHelper generator, string action, object values)
|
||||
{
|
||||
return generator.Action(action, null, values);
|
||||
}
|
||||
|
||||
public static string Action([NotNull] this IRenderUrl generator, string action, string controller)
|
||||
public static string Action([NotNull] this IUrlHelper generator, string action, string controller)
|
||||
{
|
||||
return generator.Action(action, controller, null);
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
public IServiceProvider ServiceProvider { get; private set; }
|
||||
|
||||
public IRenderUrl Url { get; set; }
|
||||
public IUrlHelper Url { get; set; }
|
||||
|
||||
public ViewData ViewData { get; private set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue