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.NETFramework4.0System.dll #endregion |