Application​Data​Composite​Value Application​Data​Composite​Value Application​Data​Composite​Value Class

Definition

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

public : sealed class ApplicationDataCompositeValue : IIterable, IMap, IObservableMap, IPropertySetpublic sealed class ApplicationDataCompositeValue : IEnumerable, IDictionary, IObservableMap, IPropertySetPublic NotInheritable Class ApplicationDataCompositeValue Implements IEnumerable, IDictionary, IObservableMap, IPropertySet
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

This example creates and reads a composite setting named exampleCompositeSetting.

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

var applicationData = Windows.Storage.ApplicationData.current;

var localSettings = applicationData.localSettings;

// Create a composite setting

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

localSettings.values["exampleCompositeSetting"] = composite;

// Read data from a composite setting

var composite = localSettings.values["exampleCompositeSetting"];

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

// Delete a composite setting

localSettings.values.remove("exampleCompositeSetting");
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");
Dim localSettings As Windows.Storage.ApplicationDataContainer = Windows.Storage.ApplicationData.Current.LocalSettings

' Create a composite setting

Dim composite As New Windows.Storage.ApplicationDataCompositeValue
composite("intVal") = 1
composite("strVal") = "string";

localSettings.Values("exampleCompositeSetting") = composite

' Read data from a composite setting

Dim composite As Windows.Storage.ApplicationDataCompositeValue = 
   CType(localSettings.Values("exampleCompositeSetting"), Windows.Storage.ApplicationDataCompositeValue)

If composite Is Nothing Then
   ' No data
Else
   ' Access data in composite("intVal") and composite("strVal")
End If

' Delete a composite setting

localSettings.Values.Remove("exampleCompositeSetting")
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;

// Create a composite setting

ApplicationDataCompositeValue^ composite = ref new ApplicationDataCompositeValue();
composite->Insert("intVal", dynamic_cast<PropertyValue^>(PropertyValue::CreateInt32(1)));
composite->Insert("strVal", dynamic_cast<PropertyValue^>(PropertyValue::CreateString("string")));

auto values = localSettings->Values;
values->Insert("exampleCompositeSetting", composite);

// Read data from a composite setting

ApplicationDataCompositeValue^ composite = 
   safe_cast<ApplicationDataCompositeValue^>(localSettings->Values->Lookup("exampleCompositeSetting"));

if (composite == nullptr)
{
   // No data
}
else
{
   int one = safe_cast<IPropertyValue^>(composite->Lookup("intVal"))->GetInt32();
   String^ hello = safe_cast<String^>(composite->Lookup("strVal"));
}

// Delete a composite setting

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() ApplicationDataCompositeValue() ApplicationDataCompositeValue()

Properties

Item[TKey] Item[TKey] Item[TKey]

Gets or sets the element with the specified key.

This member is not implemented in C++TValue this[TKey key] { get; set; }Property Item(key As TKey) As TValue
Parameters
key
TKey TKey TKey

The key of the element to get or set.

Value
TValue TValue TValue

The element with the specified key.

Attributes
Exceptions

key is null.

The property is retrieved and key is not found.

The property is set and the System.Collections.Generic.IDictionary`2 is read-only.

Keys Keys Keys

Gets an System.Collections.Generic.ICollection`1 containing the keys of the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++ICollection<TKey> Keys { get; }ReadOnly Property Keys As ICollection(Of TKey)
Value

An System.Collections.Generic.ICollection`1 containing the keys of the object that implements System.Collections.Generic.IDictionary`2.

Attributes

Size Size Size

Gets the number of related application settings.

public : unsigned short Size { get; }This member is not implemented in C#This member is not implemented in VB.Net
Value
unsigned short uint uint

The number of related settings.

Attributes

Values Values Values

Gets an System.Collections.Generic.ICollection`1 containing the values in the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++ICollection<TValue> Values { get; }ReadOnly Property Values As ICollection(Of TValue)
Value

An System.Collections.Generic.ICollection`1 containing the values in the object that implements System.Collections.Generic.IDictionary`2.

Attributes

Methods

Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue)

Adds an element with the provided key and value to the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++void Add(TKey key, TValue value)Sub Add(key As TKey, value As TValue)
Parameters
key
TKey TKey TKey

The object to use as the key of the element to add.

value
TValue TValue TValue

The object to use as the value of the element to add.

Attributes
Exceptions

key is null.

An element with the same key already exists in the System.Collections.Generic.IDictionary`2.

The System.Collections.Generic.IDictionary`2 is read-only.

Clear() Clear() Clear()

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

public : void Clear()This member is not implemented in C#This member is not implemented in VB.Net
Attributes

ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey)

Determines whether the System.Collections.Generic.IDictionary`2 contains an element with the specified key.

This member is not implemented in C++bool ContainsKey(TKey key)Function ContainsKey(key As TKey) As Boolean
Parameters
key
TKey TKey TKey

The key to locate in the System.Collections.Generic.IDictionary`2.

Returns

true if the System.Collections.Generic.IDictionary`2 contains an element with the key; otherwise, false.

Attributes
Exceptions

key is null.

First() First() First()

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

public : IIterator<IKeyValuePair<PlatForm::String, PlatForm::Object>> First()This member is not implemented in C#This member is not implemented in VB.Net
Returns
IIterator<IKeyValuePair<PlatForm::String, PlatForm::Object>> IIterator<KeyValuePair<string, object>> IIterator<KeyValuePair<string, object>>

The iterator.

Attributes

Remarks

This iterator remains valid even if the composite value's contents are mutated. If the composite value is mutated, you must get a new iterator to see the updated contents of the composite value.

GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the collection.

This member is not implemented in C++IEnumerator<T> GetEnumerator()Function GetEnumerator As IEnumerator(Of T)
Returns

An enumerator that can be used to iterate through the collection.

Attributes

GetView() GetView() GetView()

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

public : IMapView<PlatForm::String, PlatForm::Object> GetView()This member is not implemented in C#This member is not implemented in VB.Net
Returns
IMapView<PlatForm::String, PlatForm::Object> IReadOnlyDictionary<string, object> IReadOnlyDictionary<string, object>

The view of the composite value.

Attributes

Remarks

If the composite value is mutated, you must get a new view to see the updated contents of the composite value.

HasKey(String) HasKey(String) HasKey(String)

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

public : PlatForm::Boolean HasKey(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key.

Returns
PlatForm::Boolean bool bool

True if the key is found; otherwise false.

Attributes

Insert(String, Object) Insert(String, Object) Insert(String, Object)

Creates or replaces an application setting.

public : PlatForm::Boolean Insert(PlatForm::String key, PlatForm::Object value)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the setting to insert or replace.

value
PlatForm::Object Object Object

The setting value.

Returns
PlatForm::Boolean bool bool

True if an item with the specified key is an existing item and was replaced; otherwise, false.

Attributes

Lookup(String) Lookup(String) Lookup(String)

Retrieves the specified application setting.

public : PlatForm::Object Lookup(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the setting.

Returns
PlatForm::Object object object

The value, if an item with the specified key exists. Use the HasKey method to determine whether the key exists.

Attributes

Remove(TKey) Remove(TKey) Remove(TKey)

Removes the element with the specified key from the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++bool Remove(TKey key)Function Remove(key As TKey) As Boolean
Parameters
key
TKey TKey TKey

The key of the element to remove.

Returns

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original System.Collections.Generic.IDictionary`2.

Attributes
Exceptions

key is null.

The System.Collections.Generic.IDictionary`2 is read-only.

Remove(String) Remove(String) Remove(String)

Removes the value with the specified key.

public : void Remove(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the value to remove.

Attributes

TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue)

Gets the value associated with the specified key.

This member is not implemented in C++bool TryGetValue(TKey key, out TValue value)Function TryGetValue(key As TKey, ByRef value As TValue) As Boolean
Parameters
key
TKey TKey TKey

The key whose value to get.

value
TValue TValue TValue

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

true if the object that implements System.Collections.Generic.IDictionary`2 contains an element with the specified key; otherwise, false.

Attributes
Exceptions

key is null.

Events

MapChanged MapChanged MapChanged

Occurs when the map changes.

public : event MapChangedEventHandler MapChangedpublic event MapChangedEventHandler MapChangedPublic Event MapChanged
Attributes

See Also