// 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.Reflection;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Formatters;
using Microsoft.AspNet.Mvc.Internal;
using Microsoft.Framework.Internal;
namespace Microsoft.Framework.DependencyInjection
{
///
/// Extensions for configuring MVC using an .
///
public static class MvcCoreMvcBuilderExtensions
{
public static IMvcBuilder AddFormatterMappings(
[NotNull] this IMvcBuilder builder,
[NotNull] Action setupAction)
{
builder.Services.Configure((options) => setupAction(options.FormatterMappings));
return builder;
}
///
/// Register the specified as services and as a source for controller
/// discovery.
///
/// The .
/// A sequence of controller s to register in the
/// and used for controller discovery.
/// The .
public static IMvcBuilder AddControllersAsServices(
[NotNull] this IMvcBuilder builder,
[NotNull] IEnumerable controllerTypes)
{
ControllersAsServices.AddControllersAsServices(builder.Services, controllerTypes);
return builder;
}
///
/// Registers controller types from the specified as services and as a source
/// for controller discovery.
///
/// The .
/// Assemblies to scan.
/// The .
public static IMvcBuilder AddControllersAsServices(
[NotNull] this IMvcBuilder builder,
[NotNull] IEnumerable controllerAssemblies)
{
ControllersAsServices.AddControllersAsServices(builder.Services, controllerAssemblies);
return builder;
}
}
}