ResourceCandidate 클래스

정의

지정된 NamedResource에 대해 가능한 단일 값, 해당 리소스와 연결된 한정자 및 해당 한정자에서 확인된 컨텍스트와 얼마나 잘 일치하는지를 나타냅니다.

public ref class ResourceCandidate sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ResourceCandidate final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ResourceCandidate
Public NotInheritable Class ResourceCandidate
상속
Object Platform::Object IInspectable ResourceCandidate
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

이 예제는 애플리케이션 리소스 및 지역화 샘플의 시나리오 10을 기반으로 합니다. 전체 솔루션은 샘플을 참조하세요.

private void Scenario10Button_Show_Click(object sender, RoutedEventArgs e)
{
    Button b = sender as Button;
    if (b != null)
    {
        // Use a cloned context for this scenario so that qualifier values set
        // in this scenario don't impact behavior in other scenarios that
        // use a default context for the view (crossover effects between
        // the scenarios will not be expected).
        var context = ResourceContext.GetForCurrentView().Clone();

        var selectedLanguage = Scenario10ComboBox_Language.SelectedValue;
        var selectedScale = Scenario10ComboBox_Scale.SelectedValue;
        var selectedContrast = Scenario10ComboBox_Contrast.SelectedValue;
        var selectedHomeRegion = Scenario10ComboBox_HomeRegion.SelectedValue;

        if (selectedLanguage != null)
        {
            context.QualifierValues["language"] = selectedLanguage.ToString();
        }
        if (selectedScale != null)
        {
            context.QualifierValues["scale"] = selectedScale.ToString();
        }
        if (selectedContrast != null)
        {
            context.QualifierValues["contrast"] = selectedContrast.ToString();
        }
        if (selectedHomeRegion != null)
        {
            context.QualifierValues["homeregion"] = selectedHomeRegion.ToString();
        }
        Scenario10_SearchMultipleResourceIds(context, new string[] { "LanguageOnly", "ScaleOnly", "ContrastOnly", "HomeRegionOnly", "MultiDimensional" });
    }
}

void Scenario10_SearchMultipleResourceIds(ResourceContext context, string[] resourceIds)
{
    this.Scenario10TextBlock.Text = "";
    var dimensionMap = ResourceManager.Current.MainResourceMap.GetSubtree("dimensions");

    foreach (var id in resourceIds)
    {
        NamedResource namedResource;
        if (dimensionMap.TryGetValue(id, out namedResource))
        {
            var resourceCandidates = namedResource.ResolveAll(context);
            Scenario10_ShowCandidates(id, resourceCandidates);
        }
    }
}

void Scenario10_ShowCandidates(string resourceId, IReadOnlyList<ResourceCandidate> resourceCandidates)
{
    // Print 'resourceId', 'found value', 'qualifer info', 'matching condition'
    string outText = "resourceId: dimensions\\" + resourceId + "\r\n";
    int i = 0;
    foreach (var candidate in resourceCandidates)
    {
        var value = candidate.ValueAsString;
        outText += "    Candidate " + i.ToString() + ":" + value + "\r\n";
        int j = 0;
        foreach (var qualifier in candidate.Qualifiers)
        {
            var qualifierName = qualifier.QualifierName;
            var qualifierValue = qualifier.QualifierValue;
            outText += "        Qualifer: " + qualifierName + ": " + qualifierValue + "\r\n";
            outText += "        Matching: IsMatch (" + qualifier.IsMatch.ToString() + ")  " + "IsDefault (" + qualifier.IsDefault.ToString() + ")" + "\r\n";
            j++;
        }
        i++;
    }

    this.Scenario10TextBlock.Text += outText + "\r\n";
}

설명

버전 기록

Windows 버전 SDK 버전 추가된 값
1903 18362 종류

속성

IsDefault

ResourceCandidate 를 모든 컨텍스트의 기본 대체 값으로 사용할 수 있는지 여부를 나타냅니다.

IsMatch

ResourceCandidate 가 평가된 ResourceContext 와 일치하는지 여부를 나타냅니다.

IsMatchAsDefault

ResourceCandidate 가 실제 일치, 기본 대체 값 또는 기본 대체와 혼합 일치의 결과로 평가된 ResourceContext 와 일치하는지 여부를 나타냅니다(즉, 일부 한정자를 기준으로 일치하지만 다른 한정자에는 기본 대체 값을 사용).

Kind

ResourceCandidate에 캡슐화된 리소스의 형식을 가져옵니다.

Qualifiers

ResourceCandidate와 연결된 한정자를 가져옵니다.

ValueAsString

문자열로 표현된 이 ResourceCandidate의 값을 가져옵니다.

메서드

GetQualifierValue(String)

이름이 지정된 한정자의 값을 반환합니다.

GetValueAsFileAsync()

ResourceCandidate의 값에 액세스하는 StorageFile을 비동기적으로 반환합니다. 파일인 특정 유형의 ResourceCandidate에서만 작동합니다.

GetValueAsStreamAsync()

ResourceCandidate의 값에 액세스하는 IRandomAccessStream을 비동기적으로 반환합니다.

적용 대상

추가 정보