NamedResource 클래스

정의

'Header1'이라는 문자열 리소스와 같은 단일 논리 명명된 리소스를 나타냅니다.

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

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";
}

속성

Candidates

이 명명된 리소스에 대해 가능한 모든 후보 값을 가져옵니다.

Uri

이 명명된 리소스를 참조하는 데 사용할 수 있는 URI를 가져옵니다.

메서드

Resolve()

NamedResource 개체를 기본 컨텍스트에 대해 확인하고 가장 적합한 후보를 반환합니다.

참고

해결은 Windows 8.1 후 릴리스에서 변경되거나 사용할 수 없습니다. 대신 Resolve(ResourceContext)를 사용합니다.

Resolve(ResourceContext)

제공된 컨텍스트에 대해 이 NamedResource 개체를 해결하고 가장 적합한 후보를 반환합니다.

ResolveAll()

기본 컨텍스트에 대해 이 NamedResource 개체를 확인하고 가능한 모든 후보 목록을 기본 설정 순서로 반환합니다.

참고

ResolveAll은 Windows 8.1 후 릴리스에서 변경되거나 사용할 수 없습니다. 대신 ResolveAll(ResourceContext)을 사용합니다.

ResolveAll(ResourceContext)

제공된 컨텍스트에 대해 이 NamedResource 개체를 확인하고 가능한 모든 후보 목록을 기본 설정 순서로 반환합니다.

적용 대상

추가 정보