ResourceQualifier ResourceQualifier ResourceQualifier ResourceQualifier Class

Defines the qualifiers associated with a ResourceCandidate.

Syntax

Declaration

public sealed class ResourceQualifierpublic sealed class ResourceQualifierPublic NotInheritable Class ResourceQualifierpublic sealed class ResourceQualifier

Remarks

Examples

This example is based on scenario 13 of the Application resources and localization sample. See the sample for the more complete solution.

// Create a ResourceContext.
var resourceContext = new Windows.ApplicationModel.Resources.Core.ResourceContext();

// Set the specific context for lookup of resources.
var qualifierValues = resourceContext.qualifierValues;
qualifierValues["language"] = "en-US";
qualifierValues["contrast"] = "standard";
qualifierValues["scale"] = "140";
qualifierValues["homeregion"] = "021"; // Northern America

// Resources actually reside within Scenario13 Resource Map.
var resourceIds = [
    '/Scenario13/languageOnly',
    '/Scenario13/scaleOnly',
    '/Scenario13/contrastOnly',
    '/Scenario13/homeregionOnly',
    '/Scenario13/multiDimensional',
];

var output = { str: "" };
resourceIds.forEach(function (resourceId) {
    renderNamedResource(resourceId, resourceContext, output);
});

function renderNamedResource(resourceId, resourceContext, output) {
    output.str += "Resource ID " + resourceId + ":\n";
    // Lookup the resource in the mainResourceMap (the one for this package).
    var namedResource = Windows.ApplicationModel.Resources.Core.ResourceManager.current.mainResourceMap.lookup(resourceId);

    // Return a ResourceCandidateVectorView of all possible resources candidates
    // resolved against the context in order of appropriateness.
    var resourceCandidates = namedResource.resolveAll(resourceContext);

    resourceCandidates.forEach(function (candidate, index) {
        renderCandidate(candidate, index, output);
    });
    output.str += "\n";
}

function renderCandidate(candidate, index, output) {
    // Get all the various qualifiers for the candidate (such as language, scale, contrast).
    candidate.qualifiers.forEach(function (qualifier) {
        output.str += "qualifierName: " + qualifier.qualifierName + "\n";
        output.str += "qualifierValue: " + qualifier.qualifierValue + "\n";
        output.str += "isDefault: ";
        output.str += (qualifier.isDefault) ? "true\n" : "false\n";
        output.str += "isMatch: ";
        output.str += (qualifier.isMatch) ? "true\n" : "false\n";
        output.str += "score: " + qualifier.score + "\n";
        output.str += "\n";
    });
}

Properties summary

Indicates whether this qualifier should be considered as a default match when no match is found.

Indicates whether a given qualifier for a given candidate matched the context when a named resource is resolved to a candidate for some given context.

The name of the qualifier.

The value of the qualifier.

A score that indicates how well the qualifier matched the context against which it was resolved.

Properties

  • IsDefault
    IsDefault
    IsDefault
    IsDefault

    Indicates whether this qualifier should be considered as a default match when no match is found.

    public bool IsDefault { get; }public bool IsDefault { get; }Public ReadOnly Property IsDefault As boolpublic bool IsDefault { get; }

    Property Value

    • bool
      bool
      bool
      bool

      TRUE if this candidate can be used as a default fallback value for any context; otherwise, FALSE.

  • IsMatch
    IsMatch
    IsMatch
    IsMatch

    Indicates whether a given qualifier for a given candidate matched the context when a named resource is resolved to a candidate for some given context.

    public bool IsMatch { get; }public bool IsMatch { get; }Public ReadOnly Property IsMatch As boolpublic bool IsMatch { get; }

    Property Value

    • bool
      bool
      bool
      bool

      TRUE if this qualifier matched the environment against which it was evaluated; otherwise, FALSE.

    Remarks

    If a ResourceQualifier is obtained in a scenario that does not involve resolving a named resource for some context, the value is FALSE. (For example, when all candidates are enumerated for a named resource and their qualifiers are inspected.)

    After resolving a named resource for some context, IsMatch is TRUE if the qualifier matches the context on a non-default basis (that is, the qualifier value is not designated as the default value for that qualifier). The score is non-zero, and IsDefault is FALSE.

    After resolving a named resource for some context, IsMatch is FALSE if the qualifier does not match the context on a non-default basis. (The qualifier value may or may not be the default value for that qualifier. The score may or may not be zero, according to whether the qualifier is the default value.)

  • QualifierName
    QualifierName
    QualifierName
    QualifierName

    The name of the qualifier.

    public string QualifierName { get; }public string QualifierName { get; }Public ReadOnly Property QualifierName As stringpublic string QualifierName { get; }

    Property Value

    • string
      string
      string
      string

      The name of the qualifier.

  • QualifierValue
    QualifierValue
    QualifierValue
    QualifierValue

    The value of the qualifier.

    public string QualifierValue { get; }public string QualifierValue { get; }Public ReadOnly Property QualifierValue As stringpublic string QualifierValue { get; }

    Property Value

    • string
      string
      string
      string

      The value of the qualifier.

  • Score
    Score
    Score
    Score

    A score that indicates how well the qualifier matched the context against which it was resolved.

    public double Score { get; }public double Score { get; }Public ReadOnly Property Score As doublepublic double Score { get; }

    Property Value

    • double
      double
      double
      double

      A score in the range 0.0– 1.0.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.ApplicationModel.Resources.Core.dll