Compartilhar via


Examples of how resources are chosen in the Resource Management System

These are examples of how the Resource Management System chooses resource candidates based on a particular context.

For a detailed description, see the ResourceContext section of the Resource Management System topic.

Example of choosing a resource candidate

For these files:

en/images/logo.scale-180.jpg
en/images/logo.scale-140.jpg
en/images/logo.scale-100.jpg  
fr/images/logo.scale-100.jpg
fr/images/contrast-high/logo.scale-180.jpg
fr/images/contrast-high/logo.scale-100.jpg
de/images/logo.jpg

Suppose the settings in the current context are the following:

Application language: en-US; fr-FR;
Scale: 100
Contrast: Standard

The Resource Management System throws out three files because high contrast and the German language do not match the context defined by the settings. We are left with:

en/images/logo.scale-180.jpg
en/images/logo.scale-140.jpg
en/images/logo.scale-100.jpg  
fr/images/logo.scale-100.jpg

For the remaining candidates, the Resource Management System uses the highest-priority context qualifier, language, to find that the English resources rank higher than the French ones in the settings:

en/images/logo.scale-180.jpg
en/images/logo.scale-140.jpg
en/images/logo.scale-100.jpg

Then the Resource Management System uses the second-highest priority context qualifier, scale, to determine the resource, so the resource returned is:

en/images/logo.scale-100.jpg

You can use the advanced ResolveAll method to retrieve all of the candidates in the order that they match the context settings. For the example above, ResolveAll returns candidates in the following order:

en/images/logo.scale-100.jpg  
en/images/logo.scale-140.jpg
en/images/logo.scale-180.jpg
fr/images/logo.scale-100.jpg

Example of producing a fallback choice

For these files:

en/images/logo.scale-180.jpg
en/images/logo.scale-140.jpg
en/images/logo.scale-100.jpg  
fr/images/contrast-standard/logo.scale-180.jpg
fr/images/contrast-standard/logo.scale-100.jpg
de/images/contrast-standard/logo.jpg

Suppose the current settings are the following:

User language: de-DE;
Scale: 100
Contrast: High

All the files are thrown out because they do not match the context.

So we go into a default pass, where the default (see Compiling resources (MakePRI.exe)) during creation of the PRI file was:

Language: fr-FR;
Scale: 100
Contrast: Standard

This leaves all resources that either match the current user or the default.

fr/images/contrast-standard/logo.scale-180.jpg
fr/images/contrast-standard/logo.scale-100.jpg
de/images/contrast-standard/logo.jpg

Then Resource Management System uses the highest-priority context qualifier, language, to return the named resource with the highest score.

de/images/contrast-standard/logo.jpg

Resource Management System

Resource Management System, ResourceContext

Resource Management System, Compiling resources (MakePRI.exe)

NamedResource.ResolveAll