foreach string resourceKey in ResourceManager?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deerchao

    #1

    foreach string resourceKey in ResourceManager?

    Is there any way I can get all resource keys with in a compiled and
    embedded resx file?
    Thanks!

  • Stanimir Stoyanov

    #2
    Re: foreach string resourceKey in ResourceManager ?

    "deerchao" <deerchao@gmail .comwrote in message
    news:1188639542 .178438.219060@ 22g2000hsm.goog legroups.com...
    Is there any way I can get all resource keys with in a compiled and
    embedded resx file?
    Thanks!
    >
    This can be done by enumerating the keys of the underlying ResourceSet. See
    below for a sample function (C# 2.0 and later).

    private IEnumerable<str ingGetResourceN ames(string name)
    {
    return GetResourceName s(name, Assembly.GetExe cutingAssembly( ));
    }

    private IEnumerable<str ingGetResourceN ames(string name, Assembly assembly)
    {
    ResourceManager rm = new ResourceManager (name, assembly);
    ResourceSet rs = rm.GetResourceS et(CultureInfo. CurrentUICultur e, true,
    true);

    IDictionaryEnum erator ide = rs.GetEnumerato r();

    while (ide.MoveNext() )
    {
    yield return (string)ide.Key ;
    }
    }

    Sample code:
    foreach (string key in GetResourceName s("RD.Propertie s.Resources")) // This
    is the fully qualified name of the resource set
    {
    // Do something with key...
    }

    Best Regards,
    Stanimir Stoyanov
    www.stoyanoff.info | www.aeroxp.org

    Comment

    Working...