// 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 Microsoft.Extensions.Localization;
namespace Microsoft.AspNetCore.Mvc.Localization
{
///
/// Extension methods for .
///
public static class HtmlLocalizerExtensions
{
///
/// Gets the resource for a specific name.
///
/// The .
/// The key to use.
/// The resource.
public static LocalizedHtmlString GetHtml(this IHtmlLocalizer htmlLocalizer, string name)
{
if (htmlLocalizer == null)
{
throw new ArgumentNullException(nameof(htmlLocalizer));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
return htmlLocalizer[name];
}
///
/// Gets the resource for a specific name.
///
/// The .
/// The key to use.
/// The values to format the string with.
/// The resource.
public static LocalizedHtmlString GetHtml(this IHtmlLocalizer htmlLocalizer, string name, params object[] arguments)
{
if (htmlLocalizer == null)
{
throw new ArgumentNullException(nameof(htmlLocalizer));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
return htmlLocalizer[name, arguments];
}
///
/// Gets all string resources including those for parent cultures.
///
/// The .
/// The string resources.
public static IEnumerable GetAllStrings(this IHtmlLocalizer htmlLocalizer)
{
if (htmlLocalizer == null)
{
throw new ArgumentNullException(nameof(htmlLocalizer));
}
return htmlLocalizer.GetAllStrings(includeParentCultures: true);
}
}
}