-
-
Notifications
You must be signed in to change notification settings - Fork 9
Simplify.Resources
Alexanderius edited this page Jan 23, 2021
·
3 revisions
Provides StringTable.Entry
ambient context and ResourcesStringTable
, IResourcesStringTable
for getting strings from assembly resource files.
Available at NuGet as binary package
Getting string from executing assembly:
var str = StringTable.Entry["FooString"];
Resource file should be named ProgramResources.resx
and set as Embedded Resource
.
Assembly default namespace should be equal to assembly name.
You can create a custom ResourcesStringTable
class instance with custom assembly from which to get resources:
var rst = new ResourcesStringTable(Assembly.GetAssembly(typeof (MyType)), "ProgramResources");
var str = rst["FooString"];
Specifying resource base name (in case if your default namespace is not equal to assembly name)
var rst = new ResourcesStringTable(Assembly.GetAssembly(typeof (MyType)), "ProgramResources", "YourDefaultNamespace");
var str = rst["FooString"];