using System.Resources; namespace Bloxstrap.Extensions { static class ResourceManagerEx { /// /// Returns the value of the specified string resource.
/// If the resource is not found, the resource name will be returned. ///
public static string GetStringSafe(this ResourceManager manager, string name) => manager.GetStringSafe(name, null); /// /// Returns the value of the string resource localized for the specified culture.
/// If the resource is not found, the resource name will be returned. ///
public static string GetStringSafe(this ResourceManager manager, string name, CultureInfo? culture) { string? resourceValue = manager.GetString(name, culture); return resourceValue ?? name; } } }