public virtual IDictionary <string, object> GetHtmlLocalizerInformation(IHtmlLocalizer htmlLocalizer) { if (htmlLocalizer == null) { throw new ArgumentNullException(nameof(htmlLocalizer)); } var information = new SortedDictionary <string, object> { { "Type", htmlLocalizer.GetType() } }; var internalStringLocaliser = (IStringLocalizer)this.GetInternalStringLocalizer(htmlLocalizer); // ReSharper disable InvertIf if (internalStringLocaliser != null) { foreach (var item in this.GetStringLocalizerInformation(internalStringLocaliser)) { information.Add("Internal-StringLocalizer." + item.Key, item.Value); } } // ReSharper restore InvertIf return(information); }
protected internal virtual object GetInternalStringLocalizer(IHtmlLocalizer htmlLocalizer) { if (htmlLocalizer == null) { return(null); } var internalLocalizer = htmlLocalizer.GetType().GetField("_localizer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(htmlLocalizer); if (internalLocalizer is IHtmlLocalizer internalHtmlLocalizer) { return(this.GetInternalStringLocalizer(internalHtmlLocalizer)); } return(internalLocalizer); }