c# - How does reflection work on resource repositories -


i want understand how such code works retrieve resource of specified threadui culture?

var value = resourceassembly       .gettype("namespace.foobar")       .getproperty("hello")       .getvalue(null, null) string; 

if threadui culture english, english value. if german, german value. ok, fine. how work inside?

if open generated c# file corresponding type, you'll see this:

internal static string hello {     {         return resourcemanager.getstring("hello", resourceculture);     } } 

unless specific resourceculture (by setting culture property) still null, above equivalent to:

return resourcemanager.getstring("hello", null); 

the resourcemanager property returns system.resources.resourcemanager, , if @ docs resourcemanager.getstring(string, cultureinfo) you'll see:

in desktop apps, if culture null, getstring(string, cultureinfo) method uses current ui culture obtained cultureinfo.currentuiculture property.

so that's - call library method uses current ui culture default.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -