I have a Project in which lot of resource strings are used. So, I keep them organized based on modules as a folder structure.
Like if Module A is a folder then under Module A i have the following files.
Module A
ResourceFileA1.resx
ResourceFileA2.resx
ResourceFileA1.de-DE.resx
ResourceFileA2.de-DE.resx
and similar is the structure for module B.
But I just want to have a single class file or If not possible single wrapper class (for multiple classes pertaining to each resource file) to get the resource string. I am trying something like GetString(moduleA.ResourceFileA1.String)
I have tried something that is explained here But could not get it right. Can anyone please help?
Thanks in advance,
You did not mention which version of the .NET framework you are restricted to, but assuming you are on at least .NET 2.0, you really shouldn't need to worry about manually managing your resource files. Add a new resource file through Visual Studio, and you should see an auto-generated
ResourceFileA1.resx
and
ResourceFileA1.Designer.cs
The designer file should automatically create for you a compile-time reference to any resource items you put in your file such as:
moduleA.ResourceFileA1.YourStringKey
When you add new locales (.de-DE.resx, etc), moduleA.ResourceFileA1.YourStringKey should automatically refer to the right resource file based on Thread.CurrentCulture, however if you want you can pass it in explicitly by calling GetString