Share via


ApplicationDataCompositeValue Class

Definition

Represents related app settings that must be serialized and deserialized atomically.

[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public sealed class ApplicationDataCompositeValue : IDictionary<string,object>, IEnumerable<KeyValuePair<string,object>>, IObservableMap<string,object>, IPropertySet
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class ApplicationDataCompositeValue : IDictionary<string,object>, IEnumerable<KeyValuePair<string,object>>, IObservableMap<string,object>, IPropertySet
Inheritance
Object ApplicationDataCompositeValue
Attributes
Implements
IDictionary<K,V> IDictionary<String,Object> IEnumerable<KeyValuePair<K,V>> IEnumerable<KeyValuePair<String,Object>> IObservableMap<String,Object> IPropertySet

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

This example creates and reads a composite setting named exampleCompositeSetting.

Call the Remove method to delete the exampleCompositeSetting setting when you have finished with it.

Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

// Create a composite setting

Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
composite["intVal"] = 1;
composite["strVal"] = "string";

localSettings.Values["exampleCompositeSetting"] = composite;

// Read data from a composite setting

Windows.Storage.ApplicationDataCompositeValue composite = 
   (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["exampleCompositeSetting"];

if (composite == null)
{
   // No data
}
else
{
   // Access data in composite["intVal"] and composite["strVal"]
}

// Delete a composite setting

localSettings.Values.Remove("exampleCompositeSetting");

Remarks

A composite setting is serialized by inserting it into a settings map and deserialized by looking it up from the map.

Collection member lists

For JavaScript, ApplicationDataCompositeValue supports using an index to access items.

Constructors

ApplicationDataCompositeValue()

Creates and initializes a new, initially empty, instance of the object.

Properties

Size

Gets the number of related application settings.

Methods

Clear()

Removes all application settings previously inserted into the composite value object, returning the object to its empty state.

First()

Retrieves an iterator to enumerate the settings in the composite value.

GetView()

Returns a read-only snapshot of the contents of the composite value.

HasKey(String)

Determines whether there is an application setting with the specified key.

Insert(String, Object)

Creates or replaces an application setting.

Lookup(String)

Retrieves the specified application setting.

Remove(String)

Removes the value with the specified key.

Events

MapChanged

Occurs when the map changes.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also