// 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 Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc.Internal
{
public static class AttributeRouting
{
///
/// Creates an attribute route using the provided services and provided target router.
///
/// The application services.
/// An attribute route.
public static IRouter CreateAttributeMegaRoute(IServiceProvider services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
return new AttributeRoute(
services.GetRequiredService(),
services,
actions =>
{
var handler = services.GetRequiredService();
handler.Actions = actions;
return handler;
});
}
}
}