Hello I am trying to get the value from a Key in the a resource file using reflection. However it I am struggling. I build the namespace and the culture but the value always comes out null.
public static string GetResource(string language)
{
var culture = (language == "en-US") ? string.Empty : $".{language}";
var resource = Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(x => x.Name.Contains("Test"))
.Single(x => x.Namespace == $"ConsoleApp1.Resources{culture}");
resource.GetProperty("Hello");//this is always null
return null;
}
I am not sure why this is but I know that i am getting the correct resource and I see the property in it. does anyone have any sugestions?
Hello property:
internal static string Hello {
get {
return ResourceManager.GetString("Hello", resourceCulture);
}
}
Aucun commentaire:
Enregistrer un commentaire