In many .resx files I come across something like this:
<data name=">>OurLabel.Name" xml:space="preserve">
<value>OurLabel</value>
</data>
My question is: why does the attribute name
in many cases - but not always - start with >>
?
The . resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.
Net Resource (. resx) files are a monolingual file format used in Microsoft . Net Applications. The . resx resource file format consists of XML entries, which specify objects and strings inside XML tags.
Navigate to resources from File Structure Open a . resx file in the XML (Text) editor. Press Ctrl+Alt+F or choose ReSharper | Windows | File Structure from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.
The meta:resourcekey syntax allows you use declarative syntax for Implicit Resource expressions. This is used when localizing a site for international use.
You found this in the .resx file for a Winforms form with its Localizable property set to True. >
is the xml encoding for the >
character so the property value name that is getting saved is ">>OurLabel.Name".
Other properties that you'll see treated like this are Type, Parent, ZOrder.
What is special about them is that they are design-time properties. Extra ones that are added by the designer for a control. The problem with the designer adding these properties is that they can cause ambiguity. The best example I can think of is intentionally causing such an ambiguity:
using System;
using System.ComponentModel;
using System.Windows.Forms;
class MyLabel : Label {
[Localizable(true)]
public string Type { get; set; }
}
Drop this one on a form and now there are two Type properties for the control. You'll see them back in the .resx file like this:
<data name="myLabel1.Type" xml:space="preserve">
<value>Example</value>
</data>
<data name=">>myLabel1.Type" xml:space="preserve">
<value>MyLabel, WindowsFormsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
Note the difference between "myLabel1.Type" and ">>myLabel1.Type". Problem solved.
You'll also see the "$this." prefix used. It disambiguates between the name of a property of the form and the name of a control on the form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With