1 write to Metadata
Microsoft.AspNetCore.Http.Abstractions (1)
Routing\Endpoint.cs (1)
31Metadata = metadata ?? EndpointMetadataCollection.Empty;
540 references to Metadata
CookieSample (1)
Program.cs (1)
24var authData = context.HttpContext.GetEndpoint()?.Metadata.GetMetadata<IAuthorizeData>();
Microsoft.AspNetCore.Antiforgery (1)
AntiforgeryMiddleware.cs (1)
31if (endpoint?.Metadata.GetMetadata<IAntiforgeryMetadata>() is { RequiresValidation: true })
Microsoft.AspNetCore.Authorization.Policy (4)
AuthorizationMiddleware.cs (4)
116var authorizeData = endpoint?.Metadata.GetOrderedMetadata<IAuthorizeData>() ?? Array.Empty<IAuthorizeData>(); 118var policies = endpoint?.Metadata.GetOrderedMetadata<AuthorizationPolicy>() ?? Array.Empty<AuthorizationPolicy>(); 122var requirementData = endpoint?.Metadata?.GetOrderedMetadata<IAuthorizationRequirementData>() ?? Array.Empty<IAuthorizationRequirementData>(); 172if (endpoint?.Metadata.GetMetadata<IAllowAnonymous>() != null)
Microsoft.AspNetCore.Components.Endpoints (10)
Assets\ImportMap.cs (1)
52_computedImportMapDefinition = ImportMapDefinition ?? HttpContext?.GetEndpoint()?.Metadata.GetMetadata<ImportMapDefinition>();
Builder\RazorComponentEndpointDataSource.cs (1)
135var resourceCollection = endpoints.Count > 0 ? endpoints[^1].Metadata.GetMetadata<ResourceAssetCollection>() : null;
Builder\RazorComponentsEndpointHttpContextExtensions.cs (1)
33var pageType = context.GetEndpoint()?.Metadata.GetMetadata<ComponentTypeMetadata>()?.Type;
RazorComponentEndpointInvoker.cs (3)
51var rootComponent = endpoint.Metadata.GetRequiredMetadata<RootComponentMetadata>().Type; 52var pageComponent = endpoint.Metadata.GetRequiredMetadata<ComponentTypeMetadata>().Type; 59var antiforgeryMetadata = endpoint.Metadata.GetMetadata<IAntiforgeryMetadata>();
Rendering\EndpointHtmlRenderer.cs (2)
136endpoint.Metadata.GetMetadata<ResourceCollectionUrlMetadata>() : 154private static ResourceAssetCollection? GetResourceCollection(HttpContext httpContext) => httpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
Rendering\EndpointHtmlRenderer.PrerenderingState.cs (1)
25var renderModesMetadata = httpContext.GetEndpoint()?.Metadata.GetMetadata<ConfiguredRenderModesMetadata>();
Rendering\SSRRenderModeBoundary.cs (1)
54var configuredRenderModesMetadata = httpContext.GetEndpoint()?.Metadata.GetMetadata<ConfiguredRenderModesMetadata>();
Microsoft.AspNetCore.Components.Endpoints.Tests (34)
Builder\RazorComponentsEndpointConventionBuilderExtensionsTest.cs (11)
31if (e.Metadata.GetMetadata<ComponentTypeMetadata>() == null) 36var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 55var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 74var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 95var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 117var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 139var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 162var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 188var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 214var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 242var webJSEndpoint = Assert.Single(endpoints, e => e.Metadata.Contains(obj));
HotReloadServiceTests.cs (14)
50Assert.Single(endpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 67var pageEndpoints = endpointDataSource.Endpoints.Where(e => e.Metadata.GetMetadata<RootComponentMetadata>() != null).ToList(); 85e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 95var pageEndpoints = endpointDataSource.Endpoints.Where(e => e.Metadata.GetMetadata<RootComponentMetadata>() != null).ToList(); 108var endpoint = Assert.IsType<RouteEndpoint>(Assert.Single(endpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 110Assert.DoesNotContain(endpoint.Metadata, (element) => element is TestMetadata); 118var updatedEndpoint = Assert.IsType<RouteEndpoint>(Assert.Single(endpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 120Assert.Contains(updatedEndpoint.Metadata, (element) => element is TestMetadata); 134var endpoint = Assert.IsType<RouteEndpoint>(Assert.Single(endpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 136var compositeEndpoint = Assert.IsType<RouteEndpoint>(Assert.Single(compositeEndpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 145var pageEndpoints = endpointDataSource.Endpoints.Where(e => e.Metadata.GetMetadata<RootComponentMetadata>() != null).ToList(); 146var compositePageEndpoints = compositeEndpointDataSource.Endpoints.Where(e => e.Metadata.GetMetadata<RootComponentMetadata>() != null).ToList(); 183var endpoint = Assert.IsType<RouteEndpoint>(Assert.Single(endpointDataSource.Endpoints, e => e.Metadata.GetMetadata<RootComponentMetadata>() != null)); 185Assert.DoesNotContain(endpoint.Metadata, (element) => element is TestMetadata);
RazorComponentEndpointFactoryTest.cs (9)
39Assert.Contains(endpoint.Metadata, m => m is RootComponentMetadata); 40Assert.Contains(endpoint.Metadata, m => m is ComponentTypeMetadata); 41Assert.Contains(endpoint.Metadata, m => m is SuppressLinkGenerationMetadata); 42Assert.Contains(endpoint.Metadata, m => m is AuthorizeAttribute); 43Assert.Contains(endpoint.Metadata, m => m is ConfiguredRenderModesMetadata c 47var methods = Assert.Single(endpoint.Metadata.GetOrderedMetadata<HttpMethodMetadata>()); 77Assert.Contains(endpoint.Metadata, m => m is AuthorizeAttribute); 105Assert.Contains(endpoint.Metadata, m => m is AuthorizeAttribute); 165Assert.DoesNotContain(endpoint.Metadata, m => m is AuthorizeAttribute);
Microsoft.AspNetCore.Components.Server (3)
ComponentHub.cs (1)
126var resourceCollection = Context.GetHttpContext().GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
DependencyInjection\ServerRazorComponentsBuilderExtensions.cs (2)
149for (var i = 0; i < routeEndpoint.Metadata.Count; i++) 151var metadata = routeEndpoint.Metadata[i];
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
WebAssemblyEndpointProvider.cs (2)
72for (var i = 0; i < routeEndpoint.Metadata.Count; i++) 74var metadata = routeEndpoint.Metadata[i];
Microsoft.AspNetCore.Cors (1)
Infrastructure\CorsMiddleware.cs (1)
114var corsMetadata = endpoint?.Metadata.GetMetadata<ICorsMetadata>();
Microsoft.AspNetCore.Cors.Test (3)
CorsEndpointConventionBuilderExtensionsTests.cs (3)
27var metadata = endpoint.Metadata.GetMetadata<IEnableCorsAttribute>(); 48var metadata = endpoint.Metadata.GetMetadata<ICorsPolicyMetadata>(); 70var metadata = endpoint.Metadata.GetMetadata<IEnableCorsAttribute>();
Microsoft.AspNetCore.Diagnostics (4)
DeveloperExceptionPage\DeveloperExceptionPageMiddlewareImpl.cs (2)
346Metadata = endpoint.Metadata 354var httpMethods = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods;
ExceptionHandler\ExceptionHandlerMiddlewareImpl.cs (1)
194AdditionalMetadata = exceptionHandlerFeature.Endpoint?.Metadata,
StatusCodePage\StatusCodePagesMiddleware.cs (1)
82var skipStatusCodePageMetadata = endpoint?.Metadata.GetMetadata<ISkipStatusCodePagesMetadata>();
Microsoft.AspNetCore.Diagnostics.Middleware (1)
Logging\IncomingHttpRouteUtility.cs (1)
43var parameters = endpoint?.Metadata.GetMetadata<ControllerActionDescriptor>()?.Parameters;
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (13)
JsonTranscodingServiceMethodProviderTests.cs (13)
30Assert.Equal("GET", endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 46Assert.Equal("HEAD", endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 61Assert.Equal("GET", getMethodModel.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 62Assert.Equal("/v1/additional_bindings/{name}", getMethodModel.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>()?.HttpRule.Get); 66Assert.Equal("DELETE", additionalMethodModel.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 67Assert.Equal("/v1/additional_bindings/{name}", additionalMethodModel.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>()?.HttpRule.Delete); 81Assert.Equal("POST", startFrameImport.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 82Assert.Equal("/v1/frames:startFrameImport", startFrameImport.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>()?.HttpRule.Post); 85Assert.Equal("POST", getFrameImport.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 86Assert.Equal("/v1/frames:getFrameImport", getFrameImport.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>()?.HttpRule.Post); 157Assert.Equal("GET", endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 158Assert.Equal("/v1/server_greeter/{name}", endpoint.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>()?.HttpRule.Get); 237.Where(e => e.Metadata.GetMetadata<GrpcMethodMetadata>()?.Method.Name == methodName)
Microsoft.AspNetCore.Grpc.Swagger (4)
Internal\GrpcJsonTranscodingDescriptionProvider.cs (4)
43var grpcMetadata = endpoint.Metadata.GetMetadata<GrpcJsonTranscodingMetadata>(); 74EndpointMetadata = routeEndpoint.Metadata.ToList() 92var explorerSettings = routeEndpoint.Metadata.GetMetadata<ApiExplorerSettingsAttribute>(); 98var methodMetadata = routeEndpoint.Metadata.GetMetadata<GrpcMethodMetadata>()!;
Microsoft.AspNetCore.Hosting (2)
Internal\HostingApplicationDiagnostics.cs (2)
161var disableHttpRequestDurationMetric = endpoint?.Metadata.GetMetadata<IDisableHttpMetricsMetadata>() != null || context.MetricsTagsFeature.MetricsDisabled; 162var route = endpoint?.Metadata.GetMetadata<IRouteDiagnosticsMetadata>()?.Route;
Microsoft.AspNetCore.Http (4)
Features\FormFeature.cs (1)
394var formOptionsMetadatas = endpoint.Metadata
Timeouts\RequestTimeoutsMiddleware.cs (3)
37var timeoutMetadata = endpoint?.Metadata.GetMetadata<RequestTimeoutAttribute>(); 38var policyMetadata = endpoint?.Metadata.GetMetadata<RequestTimeoutPolicy>(); 47var disableMetadata = endpoint?.Metadata.GetMetadata<DisableRequestTimeoutAttribute>();
Microsoft.AspNetCore.Http.Abstractions (6)
Metadata\IEndpointDescriptionMetadata.cs (1)
7/// Defines a contract used to specify a description in <see cref="Endpoint.Metadata"/>.
Metadata\IEndpointMetadataProvider.cs (1)
21/// Add or remove objects on the <see cref="EndpointBuilder.Metadata"/> property of the <paramref name="builder"/> to modify the <see cref="Endpoint.Metadata"/> being built.
Metadata\IEndpointParameterMetadataProvider.cs (1)
21/// Add or remove objects on the <see cref="EndpointBuilder.Metadata"/> property of the <paramref name="builder"/> to modify the <see cref="Endpoint.Metadata"/> being built.
Metadata\ISkipStatusCodePagesMetadata.cs (1)
8/// middleware in <see cref="Endpoint.Metadata"/>.
Metadata\ISummaryMetadata.cs (1)
7/// Defines a contract used to specify a summary in <see cref="Endpoint.Metadata"/>.
Metadata\ITagsMetadata.cs (1)
7/// Defines a contract used to specify a collection of tags in <see cref="Endpoint.Metadata"/>.
Microsoft.AspNetCore.Http.Connections.Tests (28)
MapConnectionHandlerTests.cs (28)
51Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 52var policies = endpoint.Metadata.GetOrderedMetadata<AuthorizationPolicy>(); 61Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 62var policies = endpoint.Metadata.GetOrderedMetadata<AuthorizationPolicy>(); 88Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 93Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 115Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 120Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 143Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 148Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 174Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 179Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 203Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 208Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 233Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 238Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 265Assert.Collection(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>(), 275Assert.Collection(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>(), 303var metaData = endpoint.Metadata.GetMetadata<NegotiateMetadata>(); 305var optionsMetaData = endpoint.Metadata.GetMetadata<HttpConnectionDispatcherOptions>(); 311Assert.Null(endpoint.Metadata.GetMetadata<NegotiateMetadata>()); 339var metaData = endpoint.Metadata.GetMetadata<NegotiateMetadata>(); 341var optionsMetaData = endpoint.Metadata.GetMetadata<HttpConnectionDispatcherOptions>(); 350Assert.Null(endpoint.Metadata.GetMetadata<NegotiateMetadata>()); 373Assert.NotNull(endpoint.Metadata.GetMetadata<IEnableCorsAttribute>()); 378Assert.NotNull(endpoint.Metadata.GetMetadata<IEnableCorsAttribute>()); 421Assert.Empty(endpoint.Metadata.GetOrderedMetadata<DisableRequestTimeoutAttribute>()); 426Assert.Single(endpoint.Metadata.GetOrderedMetadata<DisableRequestTimeoutAttribute>());
Microsoft.AspNetCore.Http.Extensions (3)
EndpointDescriptionAttribute.cs (1)
10/// Specifies a description for the endpoint in <see cref="Endpoint.Metadata"/>.
EndpointSummaryAttribute.cs (1)
11/// Specifies a summary in <see cref="Endpoint.Metadata"/>.
TagsAttribute.cs (1)
11/// Specifies a collection of tags in <see cref="Endpoint.Metadata"/>.
Microsoft.AspNetCore.Http.Extensions.Tests (68)
ProblemDetailsServiceTest.cs (1)
158context.HttpContext.GetEndpoint()?.Metadata.GetMetadata<SampleMetadata>();
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
179var generatedCodeAttribute = endpoint.Metadata.OfType<GeneratedCodeAttribute>().SingleOrDefault();
RequestDelegateGenerator\RequestDelegateCreationTests.AsParameters.cs (1)
365Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "Value" });
RequestDelegateGenerator\RequestDelegateCreationTests.Forms.cs (15)
45var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 50Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 80var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 85Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 115Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 153Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 196Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 234var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 239Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 269Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 309Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 417var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 571var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 618var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>(); 851var allAcceptsMetadata = endpoint.Metadata.OfType<IAcceptsMetadata>();
RequestDelegateGenerator\RequestDelegateCreationTests.Metadata.cs (44)
33var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 49var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 65var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>(); 79var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 93var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 107var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 121var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 136var metadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 152_ = endpoint.Metadata.OfType<CustomMetadata>().Single(m => m.Value == 42); 153_ = endpoint.Metadata.OfType<CustomMetadata>().Single(m => m.Value == 24); 167var metadata = endpoint.Metadata.OfType<CustomMetadata>().Single(); 179var responseMetadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 193var responseMetadata = endpoint.Metadata.OfType<IProducesResponseTypeMetadata>().Single(); 211Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" }); 212Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param2" }); 227Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }); 242Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType }); 257Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType }); 272Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType }); 288Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 303Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 318Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 333Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 348Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 368Assert.Contains(endpoint.Metadata, m => m is MetadataService); 388Assert.Contains(endpoint.Metadata, m => m is MetadataService); 402Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 404Assert.Contains(endpoint.Metadata, m => m is MetadataCountMetadata { Count: > 1 }); 419Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 421Assert.Contains(endpoint.Metadata, m => m is MetadataCountMetadata { Count: > 1 }); 436Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 438Assert.Contains(endpoint.Metadata, m => m is MetadataCountMetadata { Count: > 1 }); 453Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 454Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" }); 469Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 470Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }); 485Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Caller }); 486Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }); 501Assert.Contains(endpoint.Metadata, m => m is RoutePatternMetadata { RoutePattern: "/test/pattern" }); 521var filteredMetadata = endpoint.Metadata.Where( 560Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }); 561Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" }); 562Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Property }); 563Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: nameof(AddsCustomParameterMetadata.Data) });
RequestDelegateGenerator\RuntimeCreationTests.ComplexFormBinding.cs (6)
36Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 72Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 104Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 141Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 213Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault()); 250Assert.NotNull(endpoint.Metadata.OfType<IAntiforgeryMetadata>().SingleOrDefault());
Microsoft.AspNetCore.Http.Microbenchmarks (1)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
179var generatedCodeAttribute = endpoint.Metadata.OfType<GeneratedCodeAttribute>().SingleOrDefault();
Microsoft.AspNetCore.HttpLogging (1)
HttpLoggingMiddleware.cs (1)
58var loggingAttribute = context.GetEndpoint()?.Metadata.GetMetadata<HttpLoggingAttribute>();
Microsoft.AspNetCore.HttpLogging.Tests (1)
HttpLoggingEndpointConventionBuilderTests.cs (1)
30var metadata = endpoint.Metadata.GetMetadata<HttpLoggingAttribute>();
Microsoft.AspNetCore.Mvc.ApiExplorer (10)
DependencyInjection\EndpointMethodInfoApiExplorerServiceCollectionExtensions.cs (2)
13/// Extensions for configuring ApiExplorer using <see cref="Endpoint.Metadata"/>. 18/// Configures ApiExplorer using <see cref="Endpoint.Metadata"/>.
EndpointMetadataApiDescriptionProvider.cs (8)
61routeEndpoint.Metadata.GetMetadata<MethodInfo>() is { } methodInfo && 62routeEndpoint.Metadata.GetMetadata<IHttpMethodMetadata>() is { } httpMethodMetadata && 63routeEndpoint.Metadata.GetMetadata<IExcludeFromDescriptionMetadata>() is null or { ExcludeFromDescription: false }) 103GroupName = routeEndpoint.Metadata.GetMetadata<IEndpointGroupNameMetadata>()?.EndpointGroupName, 116var parameters = routeEndpoint.Metadata.GetOrderedMetadata<IParameterBindingMetadata>(); 133var acceptsMetadata = routeEndpoint.Metadata.GetMetadata<IAcceptsMetadata>(); 165AddSupportedResponseTypes(apiDescription.SupportedResponseTypes, methodInfo.ReturnType, routeEndpoint.Metadata); 166AddActionDescriptorEndpointMetadata(apiDescription.ActionDescriptor, routeEndpoint.Metadata);
Microsoft.AspNetCore.Mvc.Core (16)
Authorization\AuthorizeFilter.cs (2)
146var endpointAuthorizeData = endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>() ?? Array.Empty<IAuthorizeData>(); 225if (endpoint?.Metadata?.GetMetadata<IAllowAnonymous>() != null)
Infrastructure\ActionSelectionTable.cs (2)
91getRouteKeys: e => e.Metadata.GetMetadata<ActionDescriptor>()?.RouteValues?.Keys, 95e.Metadata.GetMetadata<ActionDescriptor>()?.RouteValues?.TryGetValue(key, out value);
Infrastructure\DefaultApiProblemDetailsWriter.cs (2)
38context.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ControllerAttribute>(); 46context.HttpContext.GetEndpoint()?.Metadata.GetMetadata<IApiBehaviorMetadata>();
Routing\ActionConstraintMatcherPolicy.cs (3)
41var action = endpoint.Metadata.GetMetadata<ActionDescriptor>(); 137var actionDescriptor = endpoint.Metadata.GetMetadata<ActionDescriptor>(); 221var dataTokens = candidate.Endpoint.Metadata.GetMetadata<IDataTokensMetadata>()?.DataTokens;
Routing\ActionEndpointFactory.cs (2)
528var dataTokens = endpoint.Metadata.GetMetadata<IDataTokensMetadata>(); 534var action = endpoint.Metadata.GetMetadata<ActionDescriptor>()!;
Routing\DynamicControllerEndpointMatcherPolicy.cs (4)
42if (endpoints[i].Metadata.GetMetadata<DynamicControllerMetadata>() != null) 48if (endpoints[i].Metadata.GetMetadata<DynamicControllerRouteValueTransformerMetadata>() != null) 83var dynamicControllerMetadata = endpoint.Metadata.GetMetadata<DynamicControllerMetadata>(); 84var transformerMetadata = endpoint.Metadata.GetMetadata<DynamicControllerRouteValueTransformerMetadata>();
Routing\DynamicControllerEndpointSelectorCache.cs (1)
28var dataSourceId = endpoint.Metadata.GetMetadata<ControllerEndpointDataSourceIdMetadata>()!;
Microsoft.AspNetCore.Mvc.Core.Test (81)
ApplicationModels\EndpointMetadataProviderTest.cs (16)
38Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType }); 49endpoint => Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType }), 50endpoint => Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.ReturnType })); 60Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" }); 71endpoint => Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" }), 72endpoint => Assert.Contains(endpoint.Metadata, m => m is ParameterNameMetadata { Name: "param1" })); 82Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }); 93endpoint => Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter }), 94endpoint => Assert.Contains(endpoint.Metadata, m => m is CustomEndpointMetadata { Source: MetadataSource.Parameter })); 120endpoint.Metadata, 158Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 179Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 200Assert.DoesNotContain(endpoint.Metadata, m => m is IAcceptsMetadata); 211endpoint => Assert.Contains(endpoint.Metadata, m => m is RoutePatternMetadata { RoutePattern: "selector1" }), 212endpoint => Assert.Contains(endpoint.Metadata, m => m is RoutePatternMetadata { RoutePattern: "selector2" })); 226if (endpoint.Metadata is not [SuppressMatchingMetadata, ..])
Routing\ActionEndpointFactoryTest.cs (4)
48var routeNameMetadata = endpoint.Metadata.GetMetadata<IRouteNameMetadata>(); 254Assert.Equal("Test", endpoint.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 255Assert.Equal("Test", endpoint.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 495var isEndpointSuppressed = endpoint.Metadata.GetMetadata<ISuppressMatchingMetadata>()?.SuppressMatching ?? false;
Routing\ControllerActionEndpointDataSourceTest.cs (61)
95Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 100Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 108Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 109Assert.Equal("1", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 110Assert.Equal("1", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 115Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 116Assert.Equal("2", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 117Assert.Equal("2", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 122Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 123Assert.Equal("Test", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 124Assert.Equal("Test", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 177Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 178Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 183Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 184Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 192Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 193Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 198Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 199Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 204Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 205Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 264Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 269Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 277Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 278Assert.Equal("1", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 279Assert.Equal("1", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 284Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 285Assert.Equal("2", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 286Assert.Equal("2", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 291Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 292Assert.Equal("Test", e.Metadata.GetMetadata<IRouteNameMetadata>().RouteName); 293Assert.Equal("NewName", e.Metadata.GetMetadata<IEndpointNameMetadata>().EndpointName); 346Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 347Assert.Equal(new[] { "Hi there", "A" }, e.Metadata.GetOrderedMetadata<string>()); 352Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 353Assert.Equal(new[] { "Hi there", "B" }, e.Metadata.GetOrderedMetadata<string>()); 361Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 362Assert.Equal(new[] { "Hi there", "A" }, e.Metadata.GetOrderedMetadata<string>()); 367Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 368Assert.Equal(new[] { "Hi there", "B" }, e.Metadata.GetOrderedMetadata<string>()); 373Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 374Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 440Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 441Assert.Equal(new[] { "group", "Hi there", "A" }, e.Metadata.GetOrderedMetadata<string>()); 442Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 447Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 448Assert.Equal(new[] { "group", "Hi there", "B" }, e.Metadata.GetOrderedMetadata<string>()); 449Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 457Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 459Assert.Equal(new[] { "group", "Hi there", "A" }, e.Metadata.GetOrderedMetadata<string>()); 460Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 465Assert.Null(e.Metadata.GetMetadata<ActionDescriptor>()); 466Assert.Equal(new[] { "group", "Hi there", "B" }, e.Metadata.GetOrderedMetadata<string>()); 467Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 472Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 474Assert.Equal(new[] { "group", "A", "Hi there" }, e.Metadata.GetOrderedMetadata<string>()); 475Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 530Assert.Equal(new[] { "A1", "A2", "C1", "C2" }, e.Metadata.GetOrderedMetadata<string>()); 535Assert.Equal(new[] { "B1", "B2", "C1", "C2" }, e.Metadata.GetOrderedMetadata<string>()); 540Assert.Equal(new[] { "C1", "C2" }, e.Metadata.GetOrderedMetadata<string>()); 548return !(endpoint.Metadata.GetMetadata<ISuppressLinkGenerationMetadata>()?.SuppressLinkGeneration == true);
Microsoft.AspNetCore.Mvc.Razor (1)
TagHelpers\UrlResolutionTagHelper.cs (1)
340return ViewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (5)
PageLoaderMatcherPolicy.cs (5)
44var page = endpoints[i].Metadata.GetMetadata<PageActionDescriptor>(); 70var page = endpoint.Metadata.GetMetadata<PageActionDescriptor>(); 77var compiled = _loader.LoadAsync(page, endpoint.Metadata); 111var page = endpoint.Metadata.GetMetadata<PageActionDescriptor>(); 114compiled = await pageLoader.LoadAsync(page, endpoint.Metadata);
Microsoft.AspNetCore.Mvc.RazorPages (8)
Infrastructure\DynamicPageEndpointMatcherPolicy.cs (6)
45if (endpoints[i].Metadata.GetMetadata<DynamicPageMetadata>() != null) 51if (endpoints[i].Metadata.GetMetadata<DynamicPageRouteValueTransformerMetadata>() != null) 85var dynamicPageMetadata = endpoint.Metadata.GetMetadata<DynamicPageMetadata>(); 86var transformerMetadata = endpoint.Metadata.GetMetadata<DynamicPageRouteValueTransformerMetadata>(); 159var metadata = loadedEndpoints[j].Metadata; 169await _loader.LoadAsync(actionDescriptor, endpoint.Metadata);
Infrastructure\DynamicPageEndpointSelectorCache.cs (2)
29if (endpoint?.Metadata == null) 34var dataSourceId = endpoint.Metadata.GetMetadata<PageEndpointDataSourceIdMetadata>();
Microsoft.AspNetCore.Mvc.RazorPages.Test (20)
Builder\PageActionEndpointConventionBuilderResourceCollectionExtensionsTest.cs (8)
33var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 54var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 75var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 97var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 120var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 143var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 169var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 195var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>();
Infrastructure\PageActionEndpointDataSourceTest.cs (12)
88Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 89Assert.Equal("Hi there", e.Metadata.GetMetadata<string>()); 158Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 159Assert.Equal(new[] { "group", "A", "Hi there" }, e.Metadata.GetOrderedMetadata<string>()); 160Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 165Assert.Same(actions[1], e.Metadata.GetMetadata<ActionDescriptor>()); 166Assert.Equal(new[] { "group", "B", "Hi there" }, e.Metadata.GetOrderedMetadata<string>()); 167Assert.NotNull(e.Metadata.GetMetadata<GroupMetadata>()); 208Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 209Assert.Equal(new[] { "A1", "A2" }, e.Metadata.GetOrderedMetadata<string>()); 256Assert.Same(actions[0], e.Metadata.GetMetadata<ActionDescriptor>()); 257Assert.Equal(new[] { "initial-metadata", "initial-metadata-observed" }, e.Metadata.GetOrderedMetadata<string>());
Microsoft.AspNetCore.Mvc.TagHelpers (3)
ResourceCollectionUtilities.cs (1)
15var assetCollection = viewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
ScriptTagHelper.cs (2)
195/// the import map will be retrieved by default from the current <see cref="Endpoint.Metadata"/>. 247var importMap = ImportMap ?? ViewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ImportMapDefinition>();
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (24)
Builder\ControllerActionEndpointConventionBuilderResourceCollectionExtensionsTest.cs (24)
33var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 36var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 41var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 63var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 66var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 71var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 94var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 97var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 102var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 125var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 128var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 133var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 157var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 160var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 165var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 189var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 192var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 197var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 224var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 227var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 232var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 259var apiController = e.Metadata.GetMetadata<ApiControllerAttribute>(); 262var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>(); 267var metadata = e.Metadata.GetMetadata<ResourceAssetCollection>();
Microsoft.AspNetCore.OpenApi (2)
Extensions\OpenApiEndpointConventionBuilderExtensions.cs (2)
24/// Adds an OpenAPI annotation to <see cref="Endpoint.Metadata" /> associated 42/// Adds an OpenAPI annotation to <see cref="Endpoint.Metadata" /> associated
Microsoft.AspNetCore.OpenApi.Tests (7)
Extensions\OpenApiRouteHandlerBuilderExtensionTests.cs (7)
34var operation = endpoint.Metadata.GetMetadata<OpenApiOperation>(); 57var operation = endpoint.Metadata.GetMetadata<OpenApiOperation>(); 84var operation = endpoint.Metadata.GetMetadata<OpenApiOperation>(); 115e => Assert.NotNull(e.Metadata.GetMetadata<OpenApiOperation>()), 116e => Assert.NotNull(e.Metadata.GetMetadata<OpenApiOperation>())); 138var operation = endpoint.Metadata.GetMetadata<OpenApiOperation>(); 176var operation = endpoint.Metadata.GetMetadata<OpenApiOperation>();
Microsoft.AspNetCore.OutputCaching (1)
OutputCacheMiddleware.cs (1)
226var metadata = httpContext.GetEndpoint()?.Metadata;
Microsoft.AspNetCore.RateLimiting (3)
RateLimitingMiddleware.cs (3)
69if (endpoint?.Metadata.GetMetadata<DisableRateLimitingAttribute>() is not null) 73var enableRateLimitingAttribute = endpoint?.Metadata.GetMetadata<EnableRateLimitingAttribute>(); 258var enableRateLimitingAttribute = context.GetEndpoint()?.Metadata.GetMetadata<EnableRateLimitingAttribute>();
Microsoft.AspNetCore.RateLimiting.Tests (3)
RateLimiterEndpointConventionBuilderExtensionsTests.cs (3)
29var metadata = endpoint.Metadata.GetMetadata<EnableRateLimitingAttribute>(); 51var metadata = endpoint.Metadata.GetMetadata<EnableRateLimitingAttribute>(); 73var metadata = endpoint.Metadata.GetMetadata<DisableRateLimitingAttribute>();
Microsoft.AspNetCore.RequestDecompression (1)
RequestDecompressionMiddleware.cs (1)
62context.GetEndpoint()?.Metadata?.GetMetadata<IRequestSizeLimitMetadata>()?.MaxRequestBodySize
Microsoft.AspNetCore.Routing (42)
Builder\OpenApiRouteHandlerBuilderExtensions.cs (1)
12/// Extension methods for adding <see cref="Endpoint.Metadata"/> that is
EndpointDataSource.cs (3)
69foreach (var metadata in routeEndpoint.Metadata) 108var routeNameMetadata = routeEndpoint.Metadata.GetMetadata<IRouteNameMetadata>(); 123var httpMethodMetadata = routeEndpoint.Metadata.GetMetadata<IHttpMethodMetadata>();
EndpointGroupNameAttribute.cs (1)
7/// Specifies the endpoint group name in <see cref="Microsoft.AspNetCore.Http.Endpoint.Metadata"/>.
EndpointMiddleware.cs (3)
41if (endpoint.Metadata.GetMetadata<IAuthorizeData>() is not null && 47if (endpoint.Metadata.GetMetadata<ICorsMetadata>() is not null && 53if (endpoint.Metadata.GetMetadata<IAntiforgeryMetadata>() is { RequiresValidation: true } &&
EndpointNameAddressScheme.cs (2)
96if (endpoint.Metadata.GetMetadata<ISuppressLinkGenerationMetadata>()?.SuppressLinkGeneration == true) 102return endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()?.EndpointName;
EndpointNameAttribute.cs (1)
9/// Specifies the endpoint name in <see cref="Endpoint.Metadata"/>.
EndpointNameMetadata.cs (1)
11/// Specifies an endpoint name in <see cref="Endpoint.Metadata"/>.
EndpointRoutingMiddleware.cs (7)
120var isFallback = endpoint.Metadata.GetMetadata<FallbackMetadata>() is not null; 131var route = endpoint.Metadata.GetMetadata<IRouteDiagnosticsMetadata>()?.Route ?? "(missing)"; 140var shortCircuitMetadata = endpoint.Metadata.GetMetadata<ShortCircuitMetadata>(); 163if (endpoint.Metadata.GetMetadata<IAuthorizeData>() is not null) 168if (endpoint.Metadata.GetMetadata<ICorsMetadata>() is not null) 173if (endpoint.Metadata.GetMetadata<IAntiforgeryMetadata>() is { RequiresValidation: true } && 304var sizeLimitMetadata = context.GetEndpoint()?.Metadata?.GetMetadata<IRequestSizeLimitMetadata>();
IEndpointGroupNameMetadata.cs (1)
9/// Defines a contract used to specify an endpoint group name in <see cref="Endpoint.Metadata"/>.
IEndpointNameMetadata.cs (1)
9/// Defines a contract use to specify an endpoint name in <see cref="Endpoint.Metadata"/>.
Internal\DfaGraphWriter.cs (1)
47if (endpoints[i] is RouteEndpoint endpoint && (endpoint.Metadata.GetMetadata<ISuppressMatchingMetadata>()?.SuppressMatching ?? false) == false)
Matching\AcceptsMatcherPolicy.cs (4)
44return endpoints.Any(e => e.Metadata.GetMetadata<IAcceptsMetadata>()?.ContentTypes.Count > 0); 61var metadata = candidates[i].Endpoint?.Metadata.GetMetadata<IAcceptsMetadata>(); 154var contentTypes = endpoint.Metadata.GetMetadata<IAcceptsMetadata>()?.ContentTypes; 176var contentTypes = endpoint.Metadata.GetMetadata<IAcceptsMetadata>()?.ContentTypes ?? Array.Empty<string>();
Matching\ContentEncodingNegotiationMatcherPolicy.cs (3)
13private protected override bool HasMetadata(Endpoint endpoint) => endpoint.Metadata.GetMetadata<ContentEncodingMetadata>() != null; 15private protected override string? GetMetadataValue(Endpoint endpoint) => endpoint.Metadata.GetMetadata<ContentEncodingMetadata>()?.Value; 25var metadata = endpoint.Metadata.GetMetadata<ContentEncodingMetadata>();
Matching\DataSourceDependentMatcher.cs (2)
50var endpointName = endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()?.EndpointName; 64if (endpoint.Metadata.GetMetadata<ISuppressMatchingMetadata>()?.SuppressMatching != true)
Matching\EndpointMetadataComparer.cs (2)
69/// a specific type of metadata from <see cref="Endpoint.Metadata"/> for comparison. 109return endpoint.Metadata.GetMetadata<TMetadata>();
Matching\HostMatcherPolicy.cs (3)
50var hosts = e.Metadata.GetMetadata<IHostMetadata>()?.Hosts; 83var hosts = candidates[i].Endpoint.Metadata.GetMetadata<IHostMetadata>()?.Hosts; 275var hostMetadata = endpoint.Metadata.GetMetadata<IHostMetadata>();
Matching\HttpMethodMatcherPolicy.cs (3)
63if (endpoints[i].Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Count > 0) 99var metadata = candidates[i].Endpoint?.Metadata.GetMetadata<IHttpMethodMetadata>(); 300var metadata = e.Metadata.GetMetadata<IHttpMethodMetadata>();
Matching\MatcherPolicy.cs (1)
53var metadata = endpoints[i].Metadata.GetMetadata<IDynamicEndpointMetadata>();
RouteValuesAddressScheme.cs (2)
100var metadata = endpoint.Metadata.GetMetadata<IRouteNameMetadata>(); 106if (endpoint.Metadata.GetMetadata<ISuppressLinkGenerationMetadata>()?.SuppressLinkGeneration == true)
Microsoft.AspNetCore.Routing.Tests (82)
Builder\FallbackEndpointRouteBuilderExtensionsTest.cs (2)
28Assert.Contains(FallbackMetadata.Instance, endpoint.Metadata); 44Assert.Contains(FallbackMetadata.Instance, endpoint.Metadata);
Builder\GroupTest.cs (8)
37var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 69var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 103var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 331Assert.Equal(new[] { "/outer", "/inner", "/foo" }, endpoint.Metadata.GetOrderedMetadata<string>()); 350Assert.True(routeEndpoint.Metadata.Count >= 1); 351Assert.Equal("/group", routeEndpoint.Metadata.GetMetadata<string>()); 356Assert.True(routeEndpoint.Metadata.Count >= 1); 357Assert.Equal("/group", routeEndpoint.Metadata.GetMetadata<string>());
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (9)
414Assert.Equal(4, endpoint.Metadata.Count); 415Assert.Equal("METHOD", GetMethod(endpoint.Metadata[0])); 416Assert.Equal("ATTRIBUTE", GetMethod(endpoint.Metadata[1])); 417Assert.Equal("BUILDER", GetMethod(endpoint.Metadata[2])); 418Assert.IsAssignableFrom<IRouteDiagnosticsMetadata>(endpoint.Metadata[3]); 420Assert.Equal("BUILDER", endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods.Single()); 449Assert.Single(endpoint.Metadata.GetOrderedMetadata<IEndpointNameMetadata>()); 467Assert.Single(endpoint.Metadata.GetOrderedMetadata<IEndpointNameMetadata>()); 486var metadata = endpoint.Metadata;
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (28)
80var metadataArray = endpoint.Metadata.OfType<IHttpMethodMetadata>().ToArray(); 89Assert.Equal("BUILDER", endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()!.HttpMethods.Single()); 102var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 122var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 148var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 186var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 270var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 290var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 310var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 334var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 354var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 374var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 398var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 418var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 438var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 465var endpointNameMetadata = Assert.Single(endpoint.Metadata.GetOrderedMetadata<IEndpointNameMetadata>()); 466var routeNameMetadata = Assert.Single(endpoint.Metadata.GetOrderedMetadata<IRouteNameMetadata>()); 472var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 493var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 523var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 564var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 668var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 688var endpointMetadata = endpoint.Metadata.GetMetadata<IAcceptsMetadata>(); 706var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 726var methodMetadata = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>(); 782var tagsMetadata = endpoint.Metadata.GetMetadata<ITagsMetadata>(); 797var endpointName = endpoint.Metadata.GetMetadata<IEndpointNameMetadata>(); 798var routeName = endpoint.Metadata.GetMetadata<IRouteNameMetadata>();
Builder\RoutingEndpointConventionBuilderExtensionsTest.cs (8)
44var metadata = endpoint.Metadata.GetMetadata<IHostMetadata>(); 115var hosts = endpoint.Metadata.GetMetadata<IHostMetadata>(); 119var @string = endpoint.Metadata.GetMetadata<string>(); 149var endpointName = endpoint.Metadata.GetMetadata<IEndpointNameMetadata>(); 152var routeName = endpoint.Metadata.GetMetadata<IRouteNameMetadata>(); 168var endpointGroupName = endpoint.Metadata.GetMetadata<IEndpointGroupNameMetadata>(); 191var metadata = endpoint.Metadata.OfType<string>().ToList(); 222var metadata = endpoint.Metadata.OfType<string>().ToArray();
CompositeEndpointDataSourceTest.cs (13)
311Assert.Collection(resolvedEndpoint.Metadata, 360Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 361Assert.Equal("initial-metadata", endpoint.Metadata.GetMetadata<string>()); 367Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 368Assert.Equal("initial-metadata", endpoint.Metadata.GetMetadata<string>()); 415Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 416Assert.Equal("initial-metadata", endpoint.Metadata.GetMetadata<string>()); 422Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 423Assert.Equal("initial-metadata", endpoint.Metadata.GetMetadata<string>()); 481Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 482Assert.Equal(new[] { "initial-metadata", "saw-last-metadata" }, endpoint.Metadata.GetOrderedMetadata<string>()); 488Assert.NotNull(endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()); 489Assert.Equal(new[] { "initial-metadata", "saw-last-metadata" }, endpoint.Metadata.GetOrderedMetadata<string>());
DefaultLinkGeneratorTest.cs (1)
745return _dataSource.Endpoints.Where(e => e.Metadata.GetMetadata<IntMetadata>().Value == address);
DefaultLinkParserTest.cs (1)
174return _dataSource.Endpoints.Where(e => e.Metadata.GetMetadata<IntMetadata>().Value == address);
Matching\DfaMatcherBuilderTest.cs (6)
3593return endpoints.Any(e => e.Metadata.GetMetadata<TestMetadata1>() != null); 3605.GroupBy(e => e.Metadata.GetMetadata<TestMetadata1>().State) 3635return endpoints.Any(e => e.Metadata.GetMetadata<TestMetadata2>() != null); 3647.GroupBy(e => e.Metadata.GetMetadata<TestMetadata2>().State) 3661return endpoints.Any(e => e.Metadata.GetMetadata<TestMetadata1>() != null); 3672.GroupBy(e => e.Metadata.GetMetadata<TestMetadata1>().State)
Matching\HttpMethodMatcherPolicyTest.cs (1)
172Assert.Equal(EndpointMetadataCollection.Empty, httpContext.GetEndpoint().Metadata);
RouteEndpointBuilderTest.cs (5)
45Assert.Collection(endpoint.Metadata, 64Assert.Collection(endpoint.Metadata, 93var httpMethodMetadata = endpoint.Metadata.GetMetadata<HttpMethodMetadata>(); 114Assert.Collection(endpoint.Metadata.GetOrderedMetadata<HttpMethodMetadata>(), 134var httpMethodMetadata = endpoint.Metadata.GetMetadata<HttpMethodMetadata>();
Microsoft.AspNetCore.SignalR.Tests (24)
MapSignalRTests.cs (24)
90Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 95Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 123Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 124var policies = endpoint.Metadata.GetOrderedMetadata<AuthorizationPolicy>(); 133Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 134var policies = endpoint.Metadata.GetOrderedMetadata<AuthorizationPolicy>(); 162Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 167Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 191Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 196Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 220Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 225Assert.Single(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>()); 252Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 257Assert.Equal(2, endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>().Count); 284Assert.Collection(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>(), 294Assert.Collection(endpoint.Metadata.GetOrderedMetadata<IAuthorizeData>(), 323Assert.Equal(typeof(AuthHub), endpoint.Metadata.GetMetadata<HubMetadata>()?.HubType); 324Assert.NotNull(endpoint.Metadata.GetMetadata<NegotiateMetadata>()); 329Assert.Equal(typeof(AuthHub), endpoint.Metadata.GetMetadata<HubMetadata>()?.HubType); 330Assert.Null(endpoint.Metadata.GetMetadata<NegotiateMetadata>()); 354Assert.Equal(typeof(AuthHub), endpoint.Metadata.GetMetadata<HubMetadata>()?.HubType); 355Assert.NotNull(endpoint.Metadata.GetMetadata<NegotiateMetadata>()); 360Assert.Equal(typeof(AuthHub), endpoint.Metadata.GetMetadata<HubMetadata>()?.HubType); 361Assert.Null(endpoint.Metadata.GetMetadata<NegotiateMetadata>());
Microsoft.AspNetCore.StaticAssets (2)
Development\StaticAssetDevelopmentRuntimeHandler.cs (1)
97var assetDescriptor = endpoint.Metadata.OfType<StaticAssetDescriptor>().Single();
StaticAssetsInvoker.cs (1)
163if (context.GetEndpoint() is Endpoint { Metadata: { } metadata } && metadata.GetMetadata<BuildAssetMetadata>() != null)
Microsoft.AspNetCore.Tests (4)
WebApplicationTests.cs (4)
2808ep => Assert.Equal("/hello", ep.Metadata.GetRequiredMetadata<IRouteDiagnosticsMetadata>().Route)); 2814ep => Assert.Equal("/hello", ep.Metadata.GetRequiredMetadata<IRouteDiagnosticsMetadata>().Route)); 2832ep => Assert.Equal("/hello", ep.Metadata.GetRequiredMetadata<IRouteDiagnosticsMetadata>().Route)); 2838ep => Assert.Equal("/hello", ep.Metadata.GetRequiredMetadata<IRouteDiagnosticsMetadata>().Route));
MinimalSample (1)
Program.cs (1)
33tags ??= endpoint?.Metadata.GetMetadata<ITagsMetadata>()?.Tags ?? Array.Empty<string>();
Mvc.RoutingWebSite (1)
Controllers\ConventionalControllerWithMetadata.cs (1)
14return Ok(HttpContext.GetEndpoint().Metadata.GetOrderedMetadata<MetadataAttribute>().Select(m => m.Value));
RoutingSandbox (1)
UseEndpointRoutingStartup.cs (1)
42foreach (var metadata in endpoint.Metadata)
RoutingWebSite (1)
UseEndpointRoutingStartup.cs (1)
71return httpContext.Response.WriteAsync((endpoint.Metadata.GetMetadata<CustomMetadata>() != null) ? "Has metadata" : "No metadata");
SignalR.Client.FunctionalTestApp (1)
Startup.cs (1)
74if (endpoint != null && endpoint.Metadata.GetMetadata<HubMetadata>() != null)
StaticFilesAuth (1)
Startup.cs (1)
49var directory = endpoint.Metadata.GetMetadata<DirectoryInfo>();