Created
March 21, 2019 20:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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