install string resource generator 1 [1]. 2.5 and run srgenerator. MSI. Add SR to your project. strings file, use . net in the existing . resx or Sr. strings File Settings Custom tool attribute: stringresourcetool or srcodegen . For example: We defined a line in the SR. Strings file:
Itemnotfoundmessage (key) = item not found in cache "R" N "tkey: {0} So we are applyingProgramYou can do this: This. primitivesresultstextbox. Text + = Sr. itemnotfoundmessage (selectitemform. itemkey) + "" R "N "; In fact, the SR. itemnotfoundmessage is defined in the automatically generated Sr. CS file: Public static string itemnotfoundmessage (string key)
{
Return keys. getstring (Keys. itemnotfoundmessage, key );
} This input method is helpful for us to unify the generation method of Error Descriptions in the application. For example, we can define the error description in the SR. Strings file: Lbs_request_cannotconnectserver = unable to connect to the remote lbs gateway server: {0} This can be used in actual calls: Catch (webexception ex)
{... SB. append ("<result resid =" "501"> "+ Sr. lbs_request_cannotconnectserver (_ URL) +" </result> "N "); ... } Other Sr. Strings definition methods include:
Name |
Value |
Comments |
Member on SR class |
Notauthorized |
You are not authorized, go away |
|
String notauthorized {Get ;} |
Argumentinvalid |
Argument {0} is not valid |
Argumentname |
String argumentinvalid (Object argumentname ); |
Connectionbad |
Connection server: {0}, database {1} invalid |
Server, DB |
String connectionbad (Object Server, object dB ); |
Otherstuff |
This {0}, is undefined: {1} |
|
String otherstuff (Object arg1, object arg2 ); |