Removed unnecessary dependency of IActionSelector in UrlHelper
This commit is contained in:
parent
b622a5b0d3
commit
1c34d88f4c
|
|
@ -18,7 +18,6 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
public class UrlHelper : IUrlHelper
|
||||
{
|
||||
private readonly IActionContextAccessor _actionContextAccessor;
|
||||
private readonly IActionSelector _actionSelector;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UrlHelper"/> class using the specified action context and
|
||||
|
|
@ -26,13 +25,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
/// </summary>
|
||||
/// <param name="actionContextAccessor">The <see cref="IActionContextAccessor"/> to access the action context
|
||||
/// of the current request.</param>
|
||||
/// <param name="actionSelector">The <see cref="IActionSelector"/> to be used for verifying the correctness of
|
||||
/// supplied parameters for a route.
|
||||
/// </param>
|
||||
public UrlHelper(IActionContextAccessor actionContextAccessor, IActionSelector actionSelector)
|
||||
public UrlHelper(IActionContextAccessor actionContextAccessor)
|
||||
{
|
||||
_actionContextAccessor = actionContextAccessor;
|
||||
_actionSelector = actionSelector;
|
||||
}
|
||||
|
||||
protected IDictionary<string, object> AmbientValues => ActionContext.RouteData.Values;
|
||||
|
|
|
|||
|
|
@ -116,8 +116,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var httpContext = new Mock<HttpContext>();
|
||||
var actionContext = GetActionContext(httpContext.Object);
|
||||
var actionContextAccessor = new ActionContextAccessor() { ActionContext = actionContext };
|
||||
var mockActionSelector = new Mock<IActionSelector>();
|
||||
var urlHelper = new UrlHelper(actionContextAccessor, mockActionSelector.Object);
|
||||
var urlHelper = new UrlHelper(actionContextAccessor);
|
||||
var serviceProvider = GetServiceProvider(urlHelper);
|
||||
|
||||
httpContext.Setup(o => o.Response)
|
||||
|
|
|
|||
|
|
@ -124,8 +124,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var httpContext = new Mock<HttpContext>();
|
||||
var actionContext = GetActionContext(httpContext.Object);
|
||||
var actionContextAccessor = new ActionContextAccessor() { ActionContext = actionContext };
|
||||
var mockActionSelector = new Mock<IActionSelector>();
|
||||
var urlHelper = new UrlHelper(actionContextAccessor, mockActionSelector.Object);
|
||||
var urlHelper = new UrlHelper(actionContextAccessor);
|
||||
var serviceProvider = GetServiceProvider(urlHelper);
|
||||
|
||||
httpContext.Setup(o => o.Response)
|
||||
|
|
|
|||
|
|
@ -883,17 +883,13 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
var services = GetServices();
|
||||
var context = CreateHttpContext(services, string.Empty);
|
||||
var actionContext = CreateActionContext(context);
|
||||
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(actionContext, actionSelector.Object);
|
||||
|
||||
return new UrlHelper(actionContext);
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelper(IServiceProvider services)
|
||||
{
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(
|
||||
services.GetRequiredService<IActionContextAccessor>(),
|
||||
actionSelector.Object);
|
||||
return new UrlHelper(services.GetRequiredService<IActionContextAccessor>());
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelper(string host)
|
||||
|
|
@ -903,9 +899,8 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
context.Request.Host = new HostString(host);
|
||||
|
||||
var actionContext = CreateActionContext(context);
|
||||
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(actionContext, actionSelector.Object);
|
||||
|
||||
return new UrlHelper(actionContext);
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelper(string host, string protocol, IRouter router)
|
||||
|
|
@ -916,15 +911,13 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
context.Request.Scheme = protocol;
|
||||
|
||||
var actionContext = CreateActionContext(context, router);
|
||||
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(actionContext, actionSelector.Object);
|
||||
|
||||
return new UrlHelper(actionContext);
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelper(IActionContextAccessor contextAccessor)
|
||||
{
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(contextAccessor, actionSelector.Object);
|
||||
return new UrlHelper(contextAccessor);
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelper(string appBase, IRouter router)
|
||||
|
|
@ -932,9 +925,8 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
var services = GetServices();
|
||||
var context = CreateHttpContext(services, appBase);
|
||||
var actionContext = CreateActionContext(context, router);
|
||||
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
return new UrlHelper(actionContext, actionSelector.Object);
|
||||
|
||||
return new UrlHelper(actionContext);
|
||||
}
|
||||
|
||||
private static UrlHelper CreateUrlHelperWithRouteCollection(IServiceProvider services, string appPrefix)
|
||||
|
|
|
|||
|
|
@ -472,8 +472,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
|
||||
var contextAccessor = GetContextAccessor(serviceProvider, routeData);
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
var urlHelper = new UrlHelper(contextAccessor, actionSelector.Object);
|
||||
var urlHelper = new UrlHelper(contextAccessor);
|
||||
serviceCollection.AddSingleton<IUrlHelper>(urlHelper);
|
||||
serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
|
|
@ -494,8 +493,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
};
|
||||
|
||||
var contextAccessor = GetContextAccessor(serviceProvider, routeData);
|
||||
var actionSelector = new Mock<IActionSelector>(MockBehavior.Strict);
|
||||
var urlHelper = new UrlHelper(contextAccessor, actionSelector.Object);
|
||||
var urlHelper = new UrlHelper(contextAccessor);
|
||||
serviceCollection.AddSingleton<IUrlHelper>(urlHelper);
|
||||
serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ namespace UrlHelperWebSite
|
|||
|
||||
public CustomUrlHelper(
|
||||
IActionContextAccessor contextAccessor,
|
||||
IActionSelector actionSelector,
|
||||
IOptions<AppOptions> appOptions)
|
||||
: base(contextAccessor, actionSelector)
|
||||
: base(contextAccessor)
|
||||
{
|
||||
_appOptions = appOptions;
|
||||
_httpContext = contextAccessor.ActionContext.HttpContext;
|
||||
|
|
|
|||
Loading…
Reference in New Issue