IPropertySet 인터페이스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
다른 여러 컬렉션 인터페이스의 상관 관계를 지정하는 키-값 쌍의 컬렉션을 나타냅니다.
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> IMap<String,Object> IDictionary<String,Object> IMap<String,IInspectable> IIterable<IKeyValuePair<K,V>> IEnumerable<KeyValuePair<K,V>> IIterable<IKeyValuePair<String,Object>> IEnumerable<KeyValuePair<String,Object>> IIterable<IKeyValuePair<String,IInspectable>> IObservableMap<String,Object> IObservableMap<String,IInspectable>
Windows 요구 사항
| 디바이스 패밀리 |
Windows 10 (10.0.10240.0에서 도입되었습니다.)
|
| API contract |
Windows.Foundation.FoundationContract (v1.0에서 도입되었습니다.)
|
예제
이 예제에서는 Windows 런타임 속성에서 반환된 IPropertySet 개체 내에서 항목을 확인하는 방법을 보여 줍니다. 특히 이 속성은 속성에서 가져옵니다 CoreApplication.Properties . 이 코드 조각은 ControlChannelTrigger HTTP 클라이언트 샘플에서 제공됩니다. C# 버전이 인덱서 사용 가능하도록 IDictionary<문자열, 개체> 캐스팅하는 방법을 확인합니다. 반면 Visual C++ 구성 요소 확장(C++/CX) 버전에서는 사용 HasKey 및 Lookup사용. 일반적으로 이 작업은 형식을 반환하는 다양한 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");
}
설명
이 인터페이스는 새 멤버를 정의하지 않는다는 측면에서 이례적입니다. 대신 동일한 형식 매개 변수 제약 조건을 공유할 수 있도록 세 가지 다른 컬렉션 인터페이스의 상관 관계를 지정합니다.
- IIterable (제약 조건 IKeyValuePair, String, Object 의 내부 제약 조건 포함)
- IMap (constraint String, Object)
- IObservableMap (constraint String, Object)
개체를 IPropertySet(제네릭이 아님)으로 캐스팅하는 경우 키에 String , 값에 대한 개체 를 사용하여 이러한 세 인터페이스의 결합된 메서드를 사용할 수 있습니다. 실용적인 구현을 위해 Windows 런타임 클래스를 PropertySet 사용합니다. IPropertySet으로 캐스팅한 후 이러한 메서드를 사용하는 방법을 알아보려면 다양한 멤버 PropertySet 에 대한 설명서를 참조하세요.
Windows 런타임 API가 값으로 사용하는 PropertySet 대부분의 경우 실제로 서명에 IPropertySet으로 표시됩니다. PropertySet 는 앱 코드에서 사용할 준비가 된 IPropertySet의 실제 구현으로 간주될 수 있습니다. JavaScript 코드는 프로토타입을 구현한 PropertySet 것처럼 모든 IPropertySet 값을 처리할 수 있습니다. 유형별 사용은 IPropertySet의 주요 시나리오입니다. 실제로 앱 코드에서 인터페이스를 구현하는 것은 덜 일반적입니다.
IPropertySet도 클래스에 ValueSet 의해 구현됩니다. ValueSet는 앱을 비활성화할 수 있는 AndContinue 메서드를 호출한 후 앱이 다시 시작될 때 복원 상태를 사용하도록 설정하는 여러 ContinuationData 속성의 값 형식입니다. ValueSet모든 ContinuationData 속성 및 AndContinue 메서드는 이 동작이 있는 Windows Phone 때문에 API만 Windows Phone. 자세한 내용은 AndContinue 메서드를 호출한 후 Windows Phone Microsoft Store 앱을 계속하는 방법을 참조하세요. ValueSet PropertySet 차이점은 속성 값이 ValueSet 값 형식임을 적용하는 것과 같은 Insert 메서드를 구현한다는 점입니다.
이벤트
| MapChanged |
맵이 변경되면 발생합니다. (다음에서 상속됨 IObservableMap<K,V>) |
적용 대상
추가 정보
피드백
다음에 대한 사용자 의견 제출 및 보기