X hits on this document

180 views

0 shares

0 downloads

0 comments

43 / 67

CUSTOM CULTURES

The result of this code might not be what you would expect. Figure 11.1 shows the resulting hierarchy.

Invariant Culture

en English

en-GB English (United Kingdom)

en-GB-Acme English (United Kingdom) Acme

en-GB-Acme-Child English (United Kingdom) Acme Child

en-GB-Acme-GrandC English (United Kingdom) Acme Grandchild

Figure 11.1

Hierarchy of custom cultures when the Parent is

set by LoadDataFromCultureInfo

The LoadDataFromCultureInfo method sets the Parent property to Culture- Info.Parent, so in the first call to BuildCulture, en-GB-Acme’s parent is en (English). In the second call to BuildCulture, en-GB-Acme-Child’s parent is also en (English) because it gets en-GB-Acme’s parent. If you were looking to create a hierarchy in which the parent is the culture from which the data is being read, you must explicitly set CultureAndRegionInfoBuilder’s Parent. Add the following line after the call to LoadDataFromCultureInfo:-

builder.Parent = cultureInfo;

The result is the hierarchy shown in Figure 11.2. Now let’s look at this subject from a different point of view. The Culture- Info.CreateSpecificCulture method creates a specific culture from either a spe- cific culture (in which case, it simply returns the same specific culture) or a neutral culture. So if you pass the French culture to CreateSpecificCulture, it returns a

19

Document info
Document views180
Page views180
Page last viewedFri Dec 09 04:54:04 UTC 2016
Pages67
Paragraphs859
Words13458

Comments