/// <summary> /// Gets the text for the passed <see cref="LText"/>. /// </summary> /// <param name="key">The <see cref="LText"/>.</param> /// <returns>The corresponding text where found; otherwise <c>null</c>.</returns> protected override string GetTextForKey(LText key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } return(_resourceManager.GetString(key.KeyAndOrText, System.Globalization.CultureInfo.InvariantCulture)); }
/// <summary> /// Gets the text for the passed <see cref="LText"/>. /// </summary> /// <param name="key">The <see cref="LText"/>.</param> /// <returns>The corresponding text where found; otherwise <c>null</c>.</returns> protected override string GetTextForKey(LText key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } return(_resourceManager.GetString(key.KeyAndOrText)); }
/// <summary> /// Gets the text for the passed <see cref="LText"/>. /// </summary> /// <param name="key">The <see cref="LText"/>.</param> /// <returns>The corresponding text where found; otherwise, the <see cref="LText.FallbackText"/> where specified. Where nothing found or specified then the key itself will be returned.</returns> public string GetText(LText key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key.KeyAndOrText == null) { return(key.FallbackText ?? throw new InvalidOperationException("LText is in an invalid state; there is no KeyAndOrText or FallbackText specified.")); } return(GetTextForKey(key) ?? key.FallbackText ?? key.KeyAndOrText ?? throw new InvalidOperationException("LText is in an invalid state; there is no KeyAndOrText or FallbackText specified.")); }
/// <summary> /// Gets the text for the passed <see cref="LText"/>. /// </summary> /// <param name="key">The <see cref="LText"/>.</param> /// <returns>The corresponding text where found; otherwise, <c>null</c>.</returns> protected abstract string GetTextForKey(LText key);
/// <summary> /// Gets the text for the passed <see cref="LText"/>. /// </summary> /// <param name="key">The <see cref="LText"/>.</param> /// <returns>The corresponding text where found; otherwise <c>null</c>.</returns> protected override string GetTextForKey(LText key) => key?.KeyAndOrText ?? throw new ArgumentNullException(nameof(key));