// 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.Extensions.DependencyInjection; namespace Microsoft.AspNet.Mvc.Controllers { /// /// A that retrieves controllers as services from the request's /// . /// public class ServiceBasedControllerActivator : IControllerActivator { /// public object Create(ActionContext actionContext, Type controllerType) { if (actionContext == null) { throw new ArgumentNullException(nameof(actionContext)); } if (controllerType == null) { throw new ArgumentNullException(nameof(controllerType)); } return actionContext.HttpContext.RequestServices.GetRequiredService(controllerType); } } }