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 obtainedcultureinfo.currentuiculture
property.
so that's - call library method uses current ui culture default.
Comments
Post a Comment