IPropertySet 인터페이스

정의

다른 여러 컬렉션 인터페이스의 상관 관계를 지정하는 키-값 쌍의 컬렉션을 나타냅니다.

public interface class IPropertySet : IIterable<IKeyValuePair<Platform::String ^, Platform::Object ^> ^>, IMap<Platform::String ^, Platform::Object ^>, IObservableMap<Platform::String ^, Platform::Object ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(2319707551, 62694, 17441, 172, 249, 29, 171, 41, 134, 130, 12)]
/// [Windows.Foundation.Metadata.HasVariant]
struct IPropertySet : IIterable<IKeyValuePair<winrt::hstring, IInspectable const&>>, IMap<winrt::hstring, IInspectable const&>, IObservableMap<winrt::hstring, IInspectable const&>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(2319707551, 62694, 17441, 172, 249, 29, 171, 41, 134, 130, 12)]
[Windows.Foundation.Metadata.HasVariant]
public interface IPropertySet : IDictionary<string,object>, IEnumerable<KeyValuePair<string,object>>, IObservableMap<string,object>
Public Interface IPropertySet
Implements IDictionary(Of String, Object), IEnumerable(Of KeyValuePair(Of String, Object)), IObservableMap(Of String, Object)
파생
특성
구현
IMap<K,V> IDictionary<K,V> IDictionary<String,Object> IMap<Platform::String,Platform::Object> IMap<winrt::hstring,IInspectable> IIterable<IKeyValuePair<K,V>> IEnumerable<KeyValuePair<K,V>> IEnumerable<KeyValuePair<String,Object>> IIterable<IKeyValuePair<Platform::String,Platform::Object>> IIterable<IKeyValuePair<winrt::hstring,IInspectable>> IObservableMap<String,Object> IObservableMap<Platform::String,Platform::Object> IObservableMap<winrt::hstring,IInspectable>

Windows 요구 사항

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

예제

이 예제에서는 Windows 런타임 속성에서 반환된 IPropertySet 개체 내의 항목을 검사 방법을 보여 줍니다. 특히 CoreApplication.Properties 속성에서 가져옵니다. 이 코드 조각은 ControlChannelTrigger HTTP 클라이언트 샘플에서 제공됩니다. C# 버전이 인덱서 사용 가능하도록 IDictionary<string,object> 로 캐스팅하는 방법을 확인합니다. 반면 Visual C++ 구성 요소 확장(C++/CX) 버전은 HasKeyLookup을 사용합니다. 일반적으로 이 작업은 형식을 반환하는 다양한 Windows 런타임 속성에서 가져오는 IPropertySet 개체로 수행합니다. 속성 집합에서 특정 키를 찾은 다음, 있는 경우 일부 앱 속성을 해당 값으로 설정합니다.

// In this example, the channel name has been hardcoded to lookup the property bag 
// for any previous contexts. The channel name may be used in more sophisticated ways 
// in case an app has multiple ControlChannelTrigger objects. 
string channelId = "channelOne";
if (((IDictionary<string, object>)CoreApplication.Properties).ContainsKey(channelId))
{
    try
    {
        AppContext appContext = null;
        lock(CoreApplication.Properties)
        {
            appContext = ((IDictionary<string, object>)CoreApplication.Properties)[channelId] as AppContext;
        }
        if (appContext != null && appContext.CommunicationInstance != null)
        {
            CommunicationModule communicationInstance = appContext.CommunicationInstance;

            // Clear any existing channels, sockets etc. 
            communicationInstance.Reset();

            // Create CCT enabled transport. 
            communicationInstance.SetUpTransport(communicationInstance.serverUri, GetType().Name);
        }
    }
    catch (Exception ex)
    {
        Diag.DebugPrint("Registering with CCT failed with: " + ex.ToString());
    }
}
else
{
    Diag.DebugPrint("Cannot find AppContext key channelOne");
}
// In this example, the channel name has been hardcoded to look up the property bag
// for any previous contexts. The channel name may be used in more sophisticated ways
// in case an app has multiple ControlChannelTrigger objects.
std::wstring channelId{ L"channelOne" };
if (CoreApplication::Properties().HasKey(channelId))
{
    try
    {
        auto appContext{ CoreApplication::Properties().Lookup(channelId).as<AppContext>() };
        if (appContext && appContext->CommunicationInstance())
        {
            CommunicationModule communicationInstance{ appContext->CommunicationInstance() };

            // Clear any existing channels, sockets etc.
            communicationInstance.Reset();

            // Create CCT enabled transport.
            communicationInstance.SetUpTransport(L"NetworkChangeTask");
        }
    }
    catch (winrt::hresult_error const& ex)
    {
        Diag::DebugPrint(L"Registering with CCT failed with: " + ex.message());
    }
}
else
{
    Diag::DebugPrint(L"Cannot find AppContext key channelOne");
}
// In this example, the channel name has been hardcoded to look up the property bag
// for any previous contexts. The channel name may be used in more sophisticated ways
// in case an app has multiple ControlChannelTrigger objects.
String^ channelId = "channelOne";
if (CoreApplication::Properties->HasKey(channelId))
{
    try
    {
        auto appContext = dynamic_cast<AppContext^>(CoreApplication::Properties->Lookup(channelId));
        if (appContext != nullptr && appContext->CommunicationInstance != nullptr)
        {
            CommunicationModule^ communicationInstance = appContext->CommunicationInstance;

            // Clear any existing channels, sockets etc. 
            communicationInstance->Reset();

            // Create CCT enabled transport 
            communicationInstance->SetUpTransport("NetworkChangeTask");
        }
    }
    catch (Exception^ ex)
    {
        Diag::DebugPrint("Registering with CCT failed with: " + ex->Message);
    }
}
else
{
    Diag::DebugPrint("Cannot find AppContext key channelOne");
}

설명

이 인터페이스는 새 멤버를 정의하지 않는다는 측면에서 비정상적입니다. 대신 동일한 형식 매개 변수 제약 조건을 공유하게 하는 세 가지 다른 컬렉션 인터페이스의 상관 관계를 지정합니다.

개체를 IPropertySet(제네릭이 아님)으로 캐스팅하는 경우 키에 String , 값에 개체 를 사용하여 이러한 세 인터페이스의 결합된 메서드를 사용할 수 있습니다. 실용적인 구현을 위해 Windows 런타임 PropertySet 클래스를 사용합니다. IPropertySet으로 캐스팅한 후 이러한 메서드를 사용하는 방법을 알아보려면 PropertySet 의 다양한 멤버에 대한 설명서를 참조하세요.

Windows 런타임 API가 PropertySet을 값으로 사용하는 많은 경우 실제로 서명에 IPropertySet으로 표시됩니다. PropertySet은 앱 코드에서 사용할 준비가 된 IPropertySet의 실제 구현으로 간주될 수 있습니다. JavaScript 코드는 PropertySet 프로토타입을 구현한 것처럼 모든 IPropertySet 값을 처리할 수 있습니다. 형식별 사용량은 IPropertySet에 대한 기본 시나리오입니다. 실제로 앱 코드에서 인터페이스를 구현하는 것은 덜 일반적입니다.

또한 IPropertySet은 ValueSet 클래스에 의해 구현됩니다. ValueSet 은 여러 ContinuationData 속성의 값 형식으로, 앱을 비활성화할 수 있는 AndContinue 메서드를 호출한 후 앱이 다시 시작될 때 상태를 복원할 수 있습니다. ValueSet 및 모든 ContinuationData 속성 및 AndContinue 메서드는 이 동작이 있는 Windows Phone 때문에 API만 Windows Phone. 자세한 내용은 AndContinue 메서드를 호출한 후 Windows Phone 스토어 앱을 계속하는 방법을 참조하세요. ValueSetPropertySet의 차이점은 Insert와 같은 메서드의 ValueSet 구현이 해당 속성 값이 값 형식임을 적용한다는 것입니다.

이벤트

MapChanged

맵이 변경되면 발생합니다.

(다음에서 상속됨 IObservableMap<K,V>)

적용 대상

추가 정보