38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Routing.Matching;
|
|
using Microsoft.AspNetCore.Routing.Patterns;
|
|
|
|
namespace Microsoft.AspNetCore.Routing
|
|
{
|
|
internal static class EndpointFactory
|
|
{
|
|
public static RouteEndpoint CreateRouteEndpoint(
|
|
string template,
|
|
object defaults = null,
|
|
object policies = null,
|
|
object requiredValues = null,
|
|
int order = 0,
|
|
string displayName = null,
|
|
params object[] metadata)
|
|
{
|
|
var d = new List<object>(metadata ?? Array.Empty<object>());
|
|
if (requiredValues != null)
|
|
{
|
|
d.Add(new RouteValuesAddressMetadata(new RouteValueDictionary(requiredValues)));
|
|
}
|
|
|
|
return new RouteEndpoint(
|
|
TestConstants.EmptyRequestDelegate,
|
|
RoutePatternFactory.Parse(template, defaults, policies),
|
|
order,
|
|
new EndpointMetadataCollection(d),
|
|
displayName);
|
|
}
|
|
}
|
|
}
|