From 73024992945f4cd98b96407bf3a9b917e0648863 Mon Sep 17 00:00:00 2001 From: dudu Date: Mon, 1 Mar 2021 12:56:27 +0800 Subject: [PATCH 1/2] Add Q133689 for https://q.cnblogs.com/q/133689/ --- Q133689/Program.cs | 50 ++++++++++++++++++++++++++++++++++++++++++ Q133689/Q133689.csproj | 17 ++++++++++++++ Q133689/Q133689.sln | 25 +++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 Q133689/Program.cs create mode 100644 Q133689/Q133689.csproj create mode 100644 Q133689/Q133689.sln diff --git a/Q133689/Program.cs b/Q133689/Program.cs new file mode 100644 index 0000000..04eab9f --- /dev/null +++ b/Q133689/Program.cs @@ -0,0 +1,50 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Routing.Patterns; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using Moq; + +namespace Q133689 +{ + class Program + { + static async Task Main(string[] args) + { + var requestPath = "/cmt/p/14408628.html"; + + var routeTemplate = "/{blogApp}/{postType}/{idOrSlug}.html"; + var routeHandler = new RouteHandler((context) => null); + + IServiceCollection services = new ServiceCollection(); + services.AddSingleton(NullLoggerFactory.Instance); + services.AddOptions(); + var sp = services.BuildServiceProvider(); + + var routeOptions = sp.GetRequiredService>(); + var inlineConstraintResolver = new DefaultInlineConstraintResolver(routeOptions, sp); + var route = new Route( + routeHandler, + routeTemplate, + defaults: null, + constraints: new RouteValueDictionary(), + dataTokens: null, + inlineConstraintResolver: inlineConstraintResolver); + + var httpContext = new DefaultHttpContext(); + httpContext.Request.Path = new PathString(requestPath); + httpContext.RequestServices = sp; + + var routeContext = new RouteContext(httpContext); + await route.RouteAsync(routeContext); + + Console.WriteLine("blogApp: " + routeContext.RouteData.Values["blogApp"]); + Console.WriteLine("postType:" + routeContext.RouteData.Values["postType"]); + Console.WriteLine("idOrSlug:" + routeContext.RouteData.Values["idOrSlug"]); + } + } +} diff --git a/Q133689/Q133689.csproj b/Q133689/Q133689.csproj new file mode 100644 index 0000000..cfe9f71 --- /dev/null +++ b/Q133689/Q133689.csproj @@ -0,0 +1,17 @@ + + + + Exe + net5.0 + + + + + + + + + + + + diff --git a/Q133689/Q133689.sln b/Q133689/Q133689.sln new file mode 100644 index 0000000..10c39d4 --- /dev/null +++ b/Q133689/Q133689.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31019.35 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Q133689", "Q133689.csproj", "{8D6FAF8C-153A-48C7-BA94-37C3928BA462}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D6FAF8C-153A-48C7-BA94-37C3928BA462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D6FAF8C-153A-48C7-BA94-37C3928BA462}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D6FAF8C-153A-48C7-BA94-37C3928BA462}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D6FAF8C-153A-48C7-BA94-37C3928BA462}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8FDB8807-4FBB-4A35-A737-82A5C18B07C4} + EndGlobalSection +EndGlobal From cbc967184d40b1eeab74134faabc4db436ea7245 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 04:56:57 +0000 Subject: [PATCH 2/2] Bump Microsoft.AspNetCore.All from 2.0.5 to 2.0.9 in /Q102939 Bumps [Microsoft.AspNetCore.All](https://github.com/aspnet/Universe) from 2.0.5 to 2.0.9. - [Release notes](https://github.com/aspnet/Universe/releases) - [Changelog](https://github.com/aspnet/Universe/blob/master/docs/CrossRepoBreakingChanges.md) - [Commits](https://github.com/aspnet/Universe/compare/2.0.5...2.0.9) Signed-off-by: dependabot[bot] --- Q102939/Q102939.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Q102939/Q102939.csproj b/Q102939/Q102939.csproj index 4f2f572..47ef911 100644 --- a/Q102939/Q102939.csproj +++ b/Q102939/Q102939.csproj @@ -9,7 +9,7 @@ - +