PropertySet 類別

定義

表示屬性集,這是一組具有字串索引鍵的 PropertyValue 物件。

public ref class PropertySet sealed : IIterable<IKeyValuePair<Platform::String ^, Platform::Object ^> ^>, IMap<Platform::String ^, Platform::Object ^>, IObservableMap<Platform::String ^, Platform::Object ^>, IPropertySet
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.FoundationContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class PropertySet final : IIterable<IKeyValuePair<winrt::hstring, IInspectable const&>>, IMap<winrt::hstring, IInspectable const&>, IObservableMap<winrt::hstring, IInspectable const&>, IPropertySet
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.FoundationContract")]
class PropertySet final : IIterable<IKeyValuePair<winrt::hstring, IInspectable const&>>, IMap<winrt::hstring, IInspectable const&>, IObservableMap<winrt::hstring, IInspectable const&>, IPropertySet
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.FoundationContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class PropertySet : IDictionary<string,object>, IEnumerable<KeyValuePair<string,object>>, IObservableMap<string,object>, IPropertySet
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.FoundationContract")]
public sealed class PropertySet : IDictionary<string,object>, IEnumerable<KeyValuePair<string,object>>, IObservableMap<string,object>, IPropertySet
function PropertySet()
Public NotInheritable Class PropertySet
Implements IDictionary(Of String, Object), IEnumerable(Of KeyValuePair(Of String, Object)), IObservableMap(Of String, Object), IPropertySet
繼承
Object Platform::Object IInspectable PropertySet
屬性
實作
IMap<K,V> IDictionary<K,V> IMap<String,Object> IDictionary<String,Object> IMap<Platform::String,Platform::Object> IMap<winrt::hstring,IInspectable> IIterable<IKeyValuePair<K,V>> IEnumerable<KeyValuePair<K,V>> IIterable<IKeyValuePair<String,Object>> 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> IPropertySet

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.FoundationContract (已於 v1.0 引進)

備註

這個類別會實作對應 (IMap < K,V> 介面) 具有 String類型的索引鍵和PropertyValue類型的值。 PropertySet 類型可讓各種Windows 執行階段 API 傳回混合值的集合,這些值仍可使用 PropertySet 的通用集合 API 逐一查看或檢查,這些 API 符合IMap < K、V> 、IDictionary < TKey、TValue >或 JavaScript 集合和列舉技術,視您的應用程式使用的語言而定。

PropertyValue 是支援大量靜態 Create* 方法的類別,可從通常為實數值型別或基本類型 (布林值、數位等) 或這些值的陣列建立刻意不具類型的值。 呼叫其中一個靜態 PropertyValue 方法之後,就可以將其傳回值視為 PropertyValue 實例 (不過,如果您查看簽章) , Create* 方法會技術上傳回 Object

不過,您通常不會以要求您自行填入 PropertyValue 值的方式使用 PropertySet 。 相反地,您通常會從Windows 執行階段 API 取得填入 PropertySet 做為傳回值,以提供集合,其中實值型別可能混合在一起,但仍依來源或案例彼此相關。 例如,當您擷取應用程式資料時取得的 LocalSettingsRoamingSettings 值屬於 ApplicationDataContainer類型,且每個值都包含 PropertySet 做為其 Values 屬性值。 當您與儲存設定的應用程式資料互動時,通常會從 ApplicationDataContainer.Values取得集合。 然後您可以:

針對使用應用程式資料之類的案例,當您有 PropertySet 時,您可以參考它,因此如果您使用[新增/插入] 將這些專案新增至 PropertySet,則會將這些專案新增至應用程式資料,並將專案從應用程式資料中移除。 如果是 對 RoamingSettings進行,則所有這類變更都會透過應用程式資料機制共用。

還有其他Windows 執行階段 API 使用 PropertySet 值作為直接值,而不是包裝在另一個類別中,例如ApplicationDataContainer。 例如, CoreApplication.Properties 會傳回 PropertySet。

從媒體和裝置報告資訊的各種屬性都使用 PropertySet,例如 PlayToReceiver.Properties。 不過,還有其他媒體/裝置屬性集不會使用 PropertySet,而是改用 MediaPropertySet,因為這些屬性的識別碼在索引鍵設定為 GUID 而非字串時會較好表示。

在許多情況下,Windows 執行階段 API 會使用 PropertySet 作為值,實際上會在簽章中顯示為IPropertySet。 PropertySet 可視為 IPropertySet 的實際實作,可供應用程式程式碼使用。 JavaScript 程式碼可以將任何 IPropertySet 值視為實作 PropertySet 原型。

集合成員清單

針對 JavaScript,PropertySet 支援使用索引來存取專案。

建構函式

PropertySet()

建立並初始化屬性集的新實例。

屬性

Size

取得屬性集中包含的專案數目。

方法

Clear()

從屬性集移除所有專案。

First()

傳回反覆運算器,以列舉屬性集中的專案。

GetView()

取得屬性集的不可變檢視。

HasKey(String)

指出屬性集是否有具有指定索引鍵的專案。

Insert(String, Object)

將專案加入至屬性集。

Lookup(String)

擷取指定索引鍵的值。

Remove(String)

從屬性集移除專案。

事件

MapChanged

發生于可觀察的地圖變更時。

適用於

另請參閱