// 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.Localization; namespace Microsoft.AspNetCore.Mvc.Localization { /// /// An that creates instances of using the /// registered . /// public class HtmlLocalizerFactory : IHtmlLocalizerFactory { private readonly IStringLocalizerFactory _factory; /// /// Creates a new . /// /// The . public HtmlLocalizerFactory(IStringLocalizerFactory localizerFactory) { if (localizerFactory == null) { throw new ArgumentNullException(nameof(localizerFactory)); } _factory = localizerFactory; } /// /// Creates an using the specified . /// /// The to load resources for. /// The . public virtual IHtmlLocalizer Create(Type resourceSource) { if (resourceSource == null) { throw new ArgumentNullException(nameof(resourceSource)); } return new HtmlLocalizer(_factory.Create(resourceSource)); } /// /// Creates an using the specified base name and location. /// /// The base name of the resource to load strings from. /// The location to load resources from. /// The . public virtual IHtmlLocalizer Create(string baseName, string location) { if (baseName == null) { throw new ArgumentNullException(nameof(baseName)); } if (location == null) { throw new ArgumentNullException(nameof(location)); } var localizer = _factory.Create(baseName, location); return new HtmlLocalizer(localizer); } } }