Skip to content

Instantly share code, notes, and snippets.

@jefferson
Created March 21, 2019 20:01
Show Gist options
  • Save jefferson/7a78f5ca62941ba76773f4373274c2d9 to your computer and use it in GitHub Desktop.
Save jefferson/7a78f5ca62941ba76773f4373274c2d9 to your computer and use it in GitHub Desktop.
Iterar em arquivos .resx e buscar por uma chave e retornar seu respectivo valor
public static string GetResourceValue(string text)
{
var prefix = text.Split('-')[0].Trim();
if (String.IsNullOrEmpty(prefix))
return estrategia;
var resource = ResourceFileName.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
var dictionaryEnumerator = resource.GetEnumerator();
while (dictionaryEnumerator.MoveNext())
{
if (dictionaryEnumerator.Key.ToString().StartsWith($"PREFIX_TO_TEST_{prefix}"))
return dictionaryEnumerator.Value.ToString();
}
return estrategia;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment