зеркало из https://github.com/aspnet/Mvc.git
React to changes in routing
This commit is contained in:
Родитель
51e74c2eba
Коммит
85a4c7edc5
|
@ -99,6 +99,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LocalizationSample.Web", "s
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ActionConstraintSample.Web", "samples\ActionConstraintSample.Web\ActionConstraintSample.Web.xproj", "{EE0BD773-4D47-4AA8-8472-5A938A3953BA}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing.Abstractions", "..\Routing\src\Microsoft.AspNet.Routing.Abstractions\Microsoft.AspNet.Routing.Abstractions.xproj", "{ED253B01-24F1-43D1-AA0B-079391E105A9}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing", "..\Routing\src\Microsoft.AspNet.Routing\Microsoft.AspNet.Routing.xproj", "{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Routing.DecisionTree.Sources", "..\Routing\src\Microsoft.AspNet.Routing.DecisionTree.Sources\Microsoft.AspNet.Routing.DecisionTree.Sources.xproj", "{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -591,6 +597,42 @@ Global
|
|||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EE0BD773-4D47-4AA8-8472-5A938A3953BA}.Release|x86.Build.0 = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{ED253B01-24F1-43D1-AA0B-079391E105A9}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1EE54D32-6CED-4206-ACF5-3DC1DD39D228}.Release|x86.Build.0 = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{ABD5AA59-6000-4A3D-A54F-4B636F725AE8}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"projects": ["src", "test/WebSites", "samples"]
|
||||
"projects": ["src", "test/WebSites", "samples", "d:\\k\\Routing\\src"]
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ using Microsoft.AspNet.Mvc.Abstractions;
|
|||
using Microsoft.AspNet.Mvc.Core;
|
||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Routing.Internal;
|
||||
using Microsoft.AspNet.Routing.Template;
|
||||
using Microsoft.AspNet.Routing.Tree;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Routing
|
||||
{
|
||||
|
@ -21,6 +23,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
private readonly IRouter _target;
|
||||
private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider;
|
||||
private readonly IInlineConstraintResolver _constraintResolver;
|
||||
private readonly ObjectPool<UriBuildingContext> _contextPool;
|
||||
private readonly UrlEncoder _urlEncoder;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
|
@ -30,6 +33,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
IRouter target,
|
||||
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
|
||||
IInlineConstraintResolver constraintResolver,
|
||||
ObjectPool<UriBuildingContext> contextPool,
|
||||
UrlEncoder urlEncoder,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
|
@ -48,6 +52,11 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
throw new ArgumentNullException(nameof(constraintResolver));
|
||||
}
|
||||
|
||||
if (contextPool == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(contextPool));
|
||||
}
|
||||
|
||||
if (urlEncoder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(urlEncoder));
|
||||
|
@ -61,6 +70,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
_target = target;
|
||||
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
|
||||
_constraintResolver = constraintResolver;
|
||||
_contextPool = contextPool;
|
||||
_urlEncoder = urlEncoder;
|
||||
_loggerFactory = loggerFactory;
|
||||
}
|
||||
|
@ -104,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
{
|
||||
routeBuilder.Add(new TreeRouteLinkGenerationEntry()
|
||||
{
|
||||
Binder = new TemplateBinder(routeInfo.ParsedTemplate, _urlEncoder, routeInfo.Defaults),
|
||||
Binder = new TemplateBinder(_urlEncoder, _contextPool, routeInfo.ParsedTemplate, routeInfo.Defaults),
|
||||
Defaults = routeInfo.Defaults,
|
||||
Constraints = routeInfo.Constraints,
|
||||
Order = routeInfo.Order,
|
||||
|
|
|
@ -5,8 +5,10 @@ using System;
|
|||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Routing.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Routing
|
||||
{
|
||||
|
@ -32,6 +34,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
|
||||
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorsCollectionProvider>();
|
||||
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
|
||||
var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
|
||||
var urlEncoder = services.GetRequiredService<UrlEncoder>();
|
||||
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
|
||||
|
||||
|
@ -39,6 +42,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
target,
|
||||
actionDescriptorProvider,
|
||||
inlineConstraintResolver,
|
||||
pool,
|
||||
urlEncoder,
|
||||
loggerFactory);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ using Microsoft.AspNet.Http.Internal;
|
|||
using Microsoft.AspNet.Mvc.Abstractions;
|
||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Routing.Internal;
|
||||
using Microsoft.AspNet.Routing.Tree;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Microsoft.Extensions.WebEncoders.Testing;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
@ -67,10 +69,14 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
.SetupGet(ad => ad.ActionDescriptors)
|
||||
.Returns(new ActionDescriptorsCollection(actionDescriptors, version: 1));
|
||||
|
||||
var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder());
|
||||
var pool = new DefaultObjectPool<UriBuildingContext>(policy);
|
||||
|
||||
var route = new AttributeRoute(
|
||||
handler.Object,
|
||||
actionDescriptorsProvider.Object,
|
||||
Mock.Of<IInlineConstraintResolver>(),
|
||||
pool,
|
||||
new UrlTestEncoder(),
|
||||
NullLoggerFactory.Instance);
|
||||
|
||||
|
|
|
@ -193,10 +193,11 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
.Returns(new RouteOptions());
|
||||
|
||||
return new ServiceCollection()
|
||||
.AddSingleton(actionDescriptorProvider.Object)
|
||||
.AddSingleton<IInlineConstraintResolver>(new DefaultInlineConstraintResolver(routeOptions.Object))
|
||||
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
|
||||
.AddSingleton<UrlEncoder>(new UrlTestEncoder())
|
||||
.AddRouting()
|
||||
.AddSingleton(actionDescriptorProvider.Object)
|
||||
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="HtmlEncode[[/UrlEncode[[Product]]/UrlEncode[[Submit]]?area=NonExistentArea&id=1#fragment]]">Product Route Non-existent Area Parameter</a>
|
||||
<a href="HtmlEncode[[/UrlEncode[[Product]]/UrlEncode[[Submit]]?UrlEncode[[area]]=UrlEncode[[NonExistentArea]]&UrlEncode[[id]]=UrlEncode[[1]]#fragment]]">Product Route Non-existent Area Parameter</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="">Non-existent Area</a>
|
||||
|
|
|
@ -576,6 +576,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
.Returns(routeOptions);
|
||||
|
||||
serviceCollection.AddSingleton<IOptions<RouteOptions>>(accessor.Object);
|
||||
serviceCollection.AddRouting();
|
||||
|
||||
serviceCollection.AddSingleton<IInlineConstraintResolver>(
|
||||
new DefaultInlineConstraintResolver(accessor.Object));
|
||||
|
|
Загрузка…
Ссылка в новой задаче