|
|
@@ -1,298 +0,0 @@
|
|
|
-//------------------------------------------------------------------------------
|
|
|
-// <auto-generated>
|
|
|
-// This code was generated by a tool.
|
|
|
-//
|
|
|
-// Changes to this file may cause incorrect behavior and will be lost if
|
|
|
-// the code is regenerated.
|
|
|
-// </auto-generated>
|
|
|
-//------------------------------------------------------------------------------
|
|
|
-#nullable enable
|
|
|
-
|
|
|
-namespace Microsoft.AspNetCore.Builder
|
|
|
-{
|
|
|
- %GENERATEDCODEATTRIBUTE%
|
|
|
- internal class SourceKey
|
|
|
- {
|
|
|
- public string Path { get; init; }
|
|
|
- public int Line { get; init; }
|
|
|
-
|
|
|
- public SourceKey(string path, int line)
|
|
|
- {
|
|
|
- Path = path;
|
|
|
- Line = line;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // This class needs to be internal so that the compiled application
|
|
|
- // has access to the strongly-typed endpoint definitions that are
|
|
|
- // generated by the compiler so that they will be favored by
|
|
|
- // overload resolution and opt the runtime in to the code generated
|
|
|
- // implementation produced here.
|
|
|
- %GENERATEDCODEATTRIBUTE%
|
|
|
- internal static class GenerateRouteBuilderEndpoints
|
|
|
- {
|
|
|
- private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
|
|
|
- private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
|
|
|
- private static readonly string[] PutVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Put };
|
|
|
- private static readonly string[] DeleteVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Delete };
|
|
|
- private static readonly string[] PatchVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Patch };
|
|
|
-
|
|
|
- internal static global::Microsoft.AspNetCore.Builder.RouteHandlerBuilder MapGet(
|
|
|
- this global::Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints,
|
|
|
- [global::System.Diagnostics.CodeAnalysis.StringSyntax("Route")] string pattern,
|
|
|
- global::System.Func<global::System.TimeOnly, global::System.String> handler,
|
|
|
- [global::System.Runtime.CompilerServices.CallerFilePath] string filePath = "",
|
|
|
- [global::System.Runtime.CompilerServices.CallerLineNumber]int lineNumber = 0)
|
|
|
- {
|
|
|
- return global::Microsoft.AspNetCore.Http.Generated.GeneratedRouteBuilderExtensionsCore.MapCore(
|
|
|
- endpoints,
|
|
|
- pattern,
|
|
|
- handler,
|
|
|
- GetVerb,
|
|
|
- filePath,
|
|
|
- lineNumber);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-namespace Microsoft.AspNetCore.Http.Generated
|
|
|
-{
|
|
|
- using System;
|
|
|
- using System.Collections;
|
|
|
- using System.Collections.Generic;
|
|
|
- using System.Collections.ObjectModel;
|
|
|
- using System.Diagnostics;
|
|
|
- using System.Diagnostics.CodeAnalysis;
|
|
|
- using System.Globalization;
|
|
|
- using System.Linq;
|
|
|
- using System.Reflection;
|
|
|
- using System.Text.Json;
|
|
|
- using System.Text.Json.Serialization.Metadata;
|
|
|
- using System.Threading.Tasks;
|
|
|
- using System.IO;
|
|
|
- using Microsoft.AspNetCore.Routing;
|
|
|
- using Microsoft.AspNetCore.Routing.Patterns;
|
|
|
- using Microsoft.AspNetCore.Builder;
|
|
|
- using Microsoft.AspNetCore.Http;
|
|
|
- using Microsoft.AspNetCore.Http.Json;
|
|
|
- using Microsoft.AspNetCore.Http.Metadata;
|
|
|
- using Microsoft.Extensions.DependencyInjection;
|
|
|
- using Microsoft.Extensions.FileProviders;
|
|
|
- using Microsoft.Extensions.Primitives;
|
|
|
- using Microsoft.Extensions.Options;
|
|
|
-
|
|
|
- using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
|
|
|
- using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
|
|
|
-
|
|
|
- file static class GeneratedRouteBuilderExtensionsCore
|
|
|
- {
|
|
|
-
|
|
|
- private static readonly Dictionary<(string, int), (MetadataPopulator, RequestDelegateFactoryFunc)> map = new()
|
|
|
- {
|
|
|
- [(@"TestMapActions.cs", 24)] = (
|
|
|
- (methodInfo, options) =>
|
|
|
- {
|
|
|
- Debug.Assert(options?.EndpointBuilder != null, "EndpointBuilder not found.");
|
|
|
- options.EndpointBuilder.Metadata.Add(new SourceKey(@"TestMapActions.cs", 24));
|
|
|
- return new RequestDelegateMetadataResult { EndpointMetadata = options.EndpointBuilder.Metadata.AsReadOnly() };
|
|
|
- },
|
|
|
- (del, options, inferredMetadataResult) =>
|
|
|
- {
|
|
|
- var handler = (Func<global::System.TimeOnly, global::System.String>)del;
|
|
|
- EndpointFilterDelegate? filteredInvocation = null;
|
|
|
-
|
|
|
- if (options?.EndpointBuilder?.FilterFactories.Count > 0)
|
|
|
- {
|
|
|
- filteredInvocation = GeneratedRouteBuilderExtensionsCore.BuildFilterDelegate(ic =>
|
|
|
- {
|
|
|
- if (ic.HttpContext.Response.StatusCode == 400)
|
|
|
- {
|
|
|
- return ValueTask.FromResult<object?>(Results.Empty);
|
|
|
- }
|
|
|
- return ValueTask.FromResult<object?>(handler(ic.GetArgument<global::System.TimeOnly>(0)));
|
|
|
- },
|
|
|
- options.EndpointBuilder,
|
|
|
- handler.Method);
|
|
|
- }
|
|
|
-
|
|
|
- Task RequestHandler(HttpContext httpContext)
|
|
|
- {
|
|
|
- var wasParamCheckFailure = false;
|
|
|
- // Endpoint Parameter: p (Type = System.TimeOnly, IsOptional = False, IsParsable = True, Source = Query)
|
|
|
- var p_raw = httpContext.Request.Query["p"];
|
|
|
- if (StringValues.IsNullOrEmpty(p_raw))
|
|
|
- {
|
|
|
- wasParamCheckFailure = true;
|
|
|
- }
|
|
|
- var p_temp = (string?)p_raw;
|
|
|
- if (!ParsableHelper<global::System.TimeOnly>.TryParse(p_temp!, CultureInfo.InvariantCulture, out var p_parsed_temp))
|
|
|
- {
|
|
|
- wasParamCheckFailure = true;
|
|
|
- }
|
|
|
- global::System.TimeOnly p_local = p_parsed_temp!;
|
|
|
-
|
|
|
- if (wasParamCheckFailure)
|
|
|
- {
|
|
|
- httpContext.Response.StatusCode = 400;
|
|
|
- return Task.CompletedTask;
|
|
|
- }
|
|
|
- httpContext.Response.ContentType ??= "text/plain";
|
|
|
- var result = handler(p_local);
|
|
|
- return httpContext.Response.WriteAsync(result);
|
|
|
- }
|
|
|
-
|
|
|
- async Task RequestHandlerFiltered(HttpContext httpContext)
|
|
|
- {
|
|
|
- var wasParamCheckFailure = false;
|
|
|
- // Endpoint Parameter: p (Type = System.TimeOnly, IsOptional = False, IsParsable = True, Source = Query)
|
|
|
- var p_raw = httpContext.Request.Query["p"];
|
|
|
- if (StringValues.IsNullOrEmpty(p_raw))
|
|
|
- {
|
|
|
- wasParamCheckFailure = true;
|
|
|
- }
|
|
|
- var p_temp = (string?)p_raw;
|
|
|
- if (!ParsableHelper<global::System.TimeOnly>.TryParse(p_temp!, CultureInfo.InvariantCulture, out var p_parsed_temp))
|
|
|
- {
|
|
|
- wasParamCheckFailure = true;
|
|
|
- }
|
|
|
- global::System.TimeOnly p_local = p_parsed_temp!;
|
|
|
-
|
|
|
- if (wasParamCheckFailure)
|
|
|
- {
|
|
|
- httpContext.Response.StatusCode = 400;
|
|
|
- }
|
|
|
- var result = await filteredInvocation(EndpointFilterInvocationContext.Create<global::System.TimeOnly>(httpContext, p_local));
|
|
|
- await GeneratedRouteBuilderExtensionsCore.ExecuteObjectResult(result, httpContext);
|
|
|
- }
|
|
|
-
|
|
|
- RequestDelegate targetDelegate = filteredInvocation is null ? RequestHandler : RequestHandlerFiltered;
|
|
|
- var metadata = inferredMetadataResult?.EndpointMetadata ?? ReadOnlyCollection<object>.Empty;
|
|
|
- return new RequestDelegateResult(targetDelegate, metadata);
|
|
|
- }),
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- internal static RouteHandlerBuilder MapCore(
|
|
|
- this IEndpointRouteBuilder routes,
|
|
|
- string pattern,
|
|
|
- Delegate handler,
|
|
|
- IEnumerable<string> httpMethods,
|
|
|
- string filePath,
|
|
|
- int lineNumber)
|
|
|
- {
|
|
|
- var (populateMetadata, createRequestDelegate) = map[(filePath, lineNumber)];
|
|
|
- return RouteHandlerServices.Map(routes, pattern, handler, httpMethods, populateMetadata, createRequestDelegate);
|
|
|
- }
|
|
|
-
|
|
|
- private static EndpointFilterDelegate BuildFilterDelegate(EndpointFilterDelegate filteredInvocation, EndpointBuilder builder, MethodInfo mi)
|
|
|
- {
|
|
|
- var routeHandlerFilters = builder.FilterFactories;
|
|
|
- var context0 = new EndpointFilterFactoryContext
|
|
|
- {
|
|
|
- MethodInfo = mi,
|
|
|
- ApplicationServices = builder.ApplicationServices,
|
|
|
- };
|
|
|
- var initialFilteredInvocation = filteredInvocation;
|
|
|
- for (var i = routeHandlerFilters.Count - 1; i >= 0; i--)
|
|
|
- {
|
|
|
- var filterFactory = routeHandlerFilters[i];
|
|
|
- filteredInvocation = filterFactory(context0, filteredInvocation);
|
|
|
- }
|
|
|
- return filteredInvocation;
|
|
|
- }
|
|
|
-
|
|
|
- private static Task ExecuteObjectResult(object? obj, HttpContext httpContext)
|
|
|
- {
|
|
|
- if (obj is IResult r)
|
|
|
- {
|
|
|
- return r.ExecuteAsync(httpContext);
|
|
|
- }
|
|
|
- else if (obj is string s)
|
|
|
- {
|
|
|
- return httpContext.Response.WriteAsync(s);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return httpContext.Response.WriteAsJsonAsync(obj);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private static Func<HttpContext, StringValues> ResolveFromRouteOrQuery(string parameterName, IEnumerable<string>? routeParameterNames)
|
|
|
- {
|
|
|
- return routeParameterNames?.Contains(parameterName, StringComparer.OrdinalIgnoreCase) == true
|
|
|
- ? (httpContext) => new StringValues((string?)httpContext.Request.RouteValues[parameterName])
|
|
|
- : (httpContext) => httpContext.Request.Query[parameterName];
|
|
|
- }
|
|
|
-
|
|
|
- private static Task WriteToResponseAsync<T>(T? value, HttpContext httpContext, JsonTypeInfo<T> jsonTypeInfo, JsonSerializerOptions options)
|
|
|
- {
|
|
|
- var runtimeType = value?.GetType();
|
|
|
- if (runtimeType is null || jsonTypeInfo.Type == runtimeType || jsonTypeInfo.PolymorphismOptions is not null)
|
|
|
- {
|
|
|
- return httpContext.Response.WriteAsJsonAsync(value!, jsonTypeInfo);
|
|
|
- }
|
|
|
-
|
|
|
- return httpContext.Response.WriteAsJsonAsync(value!, options.GetTypeInfo(runtimeType));
|
|
|
- }
|
|
|
-
|
|
|
- private static async ValueTask<(bool, T?)> TryResolveBodyAsync<T>(HttpContext httpContext, bool allowEmpty)
|
|
|
- {
|
|
|
- var feature = httpContext.Features.Get<Microsoft.AspNetCore.Http.Features.IHttpRequestBodyDetectionFeature>();
|
|
|
-
|
|
|
- if (feature?.CanHaveBody == true)
|
|
|
- {
|
|
|
- if (!httpContext.Request.HasJsonContentType())
|
|
|
- {
|
|
|
- httpContext.Response.StatusCode = StatusCodes.Status415UnsupportedMediaType;
|
|
|
- return (false, default);
|
|
|
- }
|
|
|
- try
|
|
|
- {
|
|
|
- var bodyValue = await httpContext.Request.ReadFromJsonAsync<T>();
|
|
|
- if (!allowEmpty && bodyValue == null)
|
|
|
- {
|
|
|
- httpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
|
|
|
- return (false, bodyValue);
|
|
|
- }
|
|
|
- return (true, bodyValue);
|
|
|
- }
|
|
|
- catch (IOException)
|
|
|
- {
|
|
|
- return (false, default);
|
|
|
- }
|
|
|
- catch (System.Text.Json.JsonException)
|
|
|
- {
|
|
|
- httpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
|
|
|
- return (false, default);
|
|
|
- }
|
|
|
- }
|
|
|
- return (false, default);
|
|
|
- }
|
|
|
-
|
|
|
- private static ValueTask<T?> BindAsync<T>(HttpContext context, ParameterInfo parameter)
|
|
|
- where T : class, IBindableFromHttpContext<T>
|
|
|
- {
|
|
|
- return T.BindAsync(context, parameter);
|
|
|
- }
|
|
|
-
|
|
|
- private static ValueTask<(bool, T?)> TryResolveJsonBodyOrServiceAsync<T>(HttpContext httpContext, bool isOptional, IServiceProviderIsService? serviceProviderIsService = null)
|
|
|
- {
|
|
|
- if (serviceProviderIsService is not null)
|
|
|
- {
|
|
|
- if (serviceProviderIsService.IsService(typeof(T)))
|
|
|
- {
|
|
|
- return new ValueTask<(bool, T?)>((true, httpContext.RequestServices.GetService<T>()));
|
|
|
- }
|
|
|
- }
|
|
|
- return TryResolveBodyAsync<T>(httpContext, isOptional);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- %GENERATEDCODEATTRIBUTE%
|
|
|
- file static class ParsableHelper<T> where T : IParsable<T>
|
|
|
- {
|
|
|
- public static T Parse(string s, IFormatProvider? provider) => T.Parse(s, provider);
|
|
|
- public static bool TryParse(string? s, IFormatProvider? provider, [MaybeNullWhen(returnValue: false)] out T result) => T.TryParse(s, provider, out result);
|
|
|
- }
|
|
|
-}
|