Get all resx file resource strings at once

by Miro 6. August 2008 06:09

Sometimes it's necessary to read all resource key/value pair at once. I am using Dictionary<string, string> to store the returned data:

Dictionary<string, string> result = new Dictionary<string, string>();

ResourceManager manager = new ResourceManager(typeof(MyResourceClassName));
ResourceSet resources = manager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

IDictionaryEnumerator enumerator = resources.GetEnumerator();

while (enumerator.MoveNext())
{
     result.Add((string)enumerator.Key, (string)enumerator.Value);           
}

return result;

Tags:

.NET

Powered by BlogEngine.NET
Contents copyright 2008 Mirocle Pty. Ltd. All Rights Reserved.