resx

how-to switch resx at runtime?

半世苍凉 提交于 2019-12-01 11:26:09
问题 I have a second resx file Strings.ps-ps.resx that I want to point my code to at runtime. Each resx has Designer.cs with a unique class name. Do I have to switch/wrap these things myself? ...or is there some built in approach? 回答1: You need to change your UI Culture to use a different resx file. This can be done in config <globalization uiCulture="es" culture="es-MX" /> or in code Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");; If you want to automatically adapt to the user,

How to utilize the common image resources in MVC

馋奶兔 提交于 2019-12-01 11:00:31
I have several ASP.NET MVC3 and 4 web sites. All sites are using the same resources that are separate to a library. Resources are .resx files. I'd like to use images from these resource in my html inside these sites. I wasn't using resx files before so not sure what is a good way to work with them. I think that I might create a service to provide right image from right resource file, but i guess there should be a better way. My question is what is a good way to use these images from resx files and might be it is not really good to store images in a resx? One easy way to do this is to add a

How can set the `custom tool` property of an xml file to a T4 file?

自作多情 提交于 2019-12-01 08:45:53
we know that asp.net .resx files have an custom tool for generating some c# code ( ResXFileCodeGenerator ). I have an xml file and I want to set the custom tool property of that to a T4 file. how can i bind T4 file to the xml file? You can do that with T4 Toolbox . Select the resx file in Solution Explorer and set the Custom Tool Template in the Properties window. Have a look at http://t4-editor.tangible-engineering.com/t4editor_features.html#Compare . There's a feature called "Add Code Generation Item Command" that might do the trick. 来源: https://stackoverflow.com/questions/14997308/how-can

string replace on escape characters

邮差的信 提交于 2019-12-01 03:37:46
Today I found out that putting strings in a resource file will cause them to be treated as literals, i.e putting "Text for first line \n Text for second line" will cause the escape character itself to become escaped, and so what's stored is "Text for first line \n Text for second line" - and then these come out in the display, instead of my carriage returns and tabs So what I'd like to do is use string.replace to turn \\ into \ - this doesn't seem to work. s.Replace("\\\\", "\\"); doesn't change the string at all because the string thinks there's only 1 backslash s.Replace("\\", ""); replaces

How to get Name by string Value from a .NET resource (RESX) file

孤人 提交于 2019-12-01 03:05:30
Here's how my RESX file look like: Name Value Comments Rule_seconds seconds seconds Rule_Sound Sound Sound What I want is: Name by string Value, something like below: public string GetResxNameByValue(string value) { // some code to get name value } And implement it like below: string str = GetResxNameByValue("seconds"); so that str will return Rule_seconds Thanks! This could work private string GetResxNameByValue(string value) { System.Resources.ResourceManager rm = new System.Resources.ResourceManager("YourNamespace.YourResxFileName", this.GetType().Assembly); var entry= rm.GetResourceSet

How to put HTML code into a .resx resource file?

人走茶凉 提交于 2019-11-30 22:32:09
Strange, that no one asked this before.... I am creating templated HTML emails for 4 languages. I want to put the HTML templates into my .resx files to have easy, internationalized access to them from code. Like so: .resx file: <data name="BodyTemplate" xml:space="preserve"> <value><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <title>Title</title> ... </body> </html> </value> </data> But, obviously, the compiler complains about the HTML inside the

How to get Name by string Value from a .NET resource (RESX) file

不问归期 提交于 2019-11-30 22:17:07
问题 Here's how my RESX file look like: Name Value Comments Rule_seconds seconds seconds Rule_Sound Sound Sound What I want is: Name by string Value, something like below: public string GetResxNameByValue(string value) { // some code to get name value } And implement it like below: string str = GetResxNameByValue("seconds"); so that str will return Rule_seconds Thanks! 回答1: This could work private string GetResxNameByValue(string value) { System.Resources.ResourceManager rm = new System.Resources

How to put HTML code into a .resx resource file?

穿精又带淫゛_ 提交于 2019-11-30 17:47:41
问题 Strange, that no one asked this before.... I am creating templated HTML emails for 4 languages. I want to put the HTML templates into my .resx files to have easy, internationalized access to them from code. Like so: .resx file: <data name="BodyTemplate" xml:space="preserve"> <value><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <title>Title</title> ...

App domain restarts when .resx file changes. Any way to avoid this?

两盒软妹~` 提交于 2019-11-30 16:06:11
问题 I have an ASP.NET app with many .resx (resource) files used for localized user controls and pages. We would like these files to be editable on-the-fly. However, we have noticed that editing these files on the web server causes the app domain to reload, which causes the server to slow down for about a minute while the app domain restarts. Is there any way to permit editing of these files without causing the app domain to restart? 回答1: There are several flavors of this question on Stackoverflow

How to use a resx resource file in a T4 template

房东的猫 提交于 2019-11-30 15:57:00
I cant figure out how to include the resource file (.resx) in the (.tt) T4 template. I tried so far... Importing the namespace <#@ import namespace="T4TemplateResources.resx" #> Also including the class Nico's solution requires your solution to build. There is another way, without needing to compile your solution by reading the raw resx file. var fileName = "CustomResource.resx"; var filePath = Path.Combine(Path.GetDirectoryName(this.Host.ResolvePath("")), "WindowsFormsApplication1", fileName); var reader = new ResXResourceReader(filePath); var values = reader.Cast<DictionaryEntry>()