This article is a mirror article of machine translation, please click here to jump to the original article.

View: 29086|Reply: 0

[Source] SRDescriptionAttribute makes your control property annotations multilingual

[Copy link]
Posted on 8/22/2020 9:47:25 AM | | | |
On machines in different locales, the comment information of .NET methods and properties is displayed differently, for example, under Chinese operating system, comments are displayed in Chinese, and English comments are displayed in English operating systems. NET Framework can display comments in different languages, how does he solve it?

We know that when developing a control, you can add a DescriptionAttribute tag to a property and display its comments in the property bar, like this:


But you will find that the string of comments is written dead in Chinese text, what if I want the control to display English comments in an English environment? .NET Framework can display comments in different languages, how does he solve it?

Decompilation. NET Framework, we found that his annotation does not have a DescriptionAttribute, but uses an SRDescriptionAttribute, for example:




In the comments, the .NET Framework does not write a direct English comment, but writes a resource keyword and looks at the implementation of SRDescriptionAttribute.



It was too simple and ingenious, so he overloaded the Get of the Description and got it from the resource file instead. It's that simple.



SRDescriptionAttribute class is as follows:

#region Assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFramework 4.0System.dll
#endregion




Previous:Jquery sorts the price and volume of products and filters them by price range
Next:.NET/C# Use the WebClient download to complete the file name
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com