// 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.DataAnnotations;
using Microsoft.AspNetCore.Mvc.DataAnnotations.Internal;
namespace Microsoft.Extensions.DependencyInjection
{
///
/// Extension methods for configuring MVC data annotations localization.
///
public static class MvcDataAnnotationsMvcBuilderExtensions
{
///
/// Adds MVC data annotations localization to the application.
///
/// The .
/// The .
public static IMvcBuilder AddDataAnnotationsLocalization(this IMvcBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return AddDataAnnotationsLocalization(builder, setupAction: null);
}
///
/// Adds MVC data annotations localization to the application.
///
/// The .
/// The action to configure .
///
/// The .
public static IMvcBuilder AddDataAnnotationsLocalization(
this IMvcBuilder builder,
Action setupAction)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
DataAnnotationsLocalizationServices.AddDataAnnotationsLocalizationServices(
builder.Services,
setupAction);
return builder;
}
}
}