// 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 System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing.Patterns;
namespace Microsoft.AspNetCore.Routing.Matching
{
///
/// Represents an that can be used in URL matching or URL generation.
///
public sealed class MatcherEndpoint : Endpoint
{
internal static readonly Func EmptyInvoker = (next) =>
{
return (context) => Task.CompletedTask;
};
///
/// Initializes a new instance of the class.
///
/// The delegate to invoke to create a .
/// The to use in URL matching.
/// The order assigned to the endpoint.
///
/// The or metadata associated with the endpoint.
///
/// The informational display name of the endpoint.
public MatcherEndpoint(
Func invoker,
RoutePattern routePattern,
int order,
EndpointMetadataCollection metadata,
string displayName)
: base(metadata, displayName)
{
if (invoker == null)
{
throw new ArgumentNullException(nameof(invoker));
}
if (routePattern == null)
{
throw new ArgumentNullException(nameof(routePattern));
}
Invoker = invoker;
RoutePattern = routePattern;
Order = order;
}
///
/// Gets the invoker. The invoker is a delegate used to create a .
///
public Func Invoker { get; }
///
/// Gets the order value of endpoint.
///
///
/// The order value provides absolute control over the priority
/// of an endpoint. Endpoints with a lower numeric value of order have higher priority.
///
public int Order { get; }
///
/// Gets the associated with the endpoint.
///
public RoutePattern RoutePattern { get; }
}
}