ApplicationDataCompositeValue
ApplicationDataCompositeValue
ApplicationDataCompositeValue
ApplicationDataCompositeValue
ApplicationDataCompositeValue
Class
Definition
Represents related app settings that must be serialized and deserialized atomically.
public : sealed class ApplicationDataCompositeValue : IIterable<IKeyValuePair<Platform::String, Platform::Object>>, IMap<Platform::String, Platform::Object>, IObservableMap<Platform::String, Platform::Object>, IPropertySet
struct winrt::Windows::Storage::ApplicationDataCompositeValue : IIterable<IKeyValuePair<Platform::String, Platform::Object>>, IMap<Platform::String, Platform::Object>, IObservableMap<Platform::String, Platform::Object>, IPropertySet
public sealed class ApplicationDataCompositeValue : IEnumerable<KeyValuePair<String, Object>>, IDictionary<String, Object>, IObservableMap<String, Object>, IPropertySet
Public NotInheritable Class ApplicationDataCompositeValue Implements IEnumerable<KeyValuePair<String, Object>>, IDictionary<String, Object>, IObservableMap<String, Object>, IPropertySet
var applicationDataCompositeValue = new applicationDataCompositeValue();
- Attributes
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() ApplicationDataCompositeValue() ApplicationDataCompositeValue() |
Creates and initializes a new, initially empty, instance of the object. |
Properties
Item[TKey] Item[TKey] Item[TKey] Item[TKey] Item[TKey] |
Gets or sets the element with the specified key. |
Keys Keys Keys Keys Keys |
Gets an System.Collections.Generic.ICollection`1 containing the keys of the System.Collections.Generic.IDictionary`2. |
Size Size Size Size Size |
Gets the number of related application settings. |
Values Values Values Values Values |
Gets an System.Collections.Generic.ICollection`1 containing the values in the System.Collections.Generic.IDictionary`2. |
Methods
Add(TKey, TValue) Add(TKey, TValue) 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. |
Clear() Clear() Clear() Clear() Clear() |
Removes all application settings previously inserted into the composite value object, returning the object to its empty state. |
ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) |
Determines whether the System.Collections.Generic.IDictionary`2 contains an element with the specified key. |
First() First() First() First() First() |
Retrieves an iterator to enumerate the settings in the composite value. |
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator() |
Returns an enumerator that iterates through the collection. |
GetView() GetView() GetView() GetView() GetView() |
Returns a read-only snapshot of the contents of the composite value. |
HasKey(String) HasKey(String) HasKey(String) HasKey(String) HasKey(String) |
Determines whether there is an application setting with the specified key. |
Insert(String, Object) Insert(String, Object) Insert(String, Object) Insert(String, Object) Insert(String, Object) |
Creates or replaces an application setting. |
Lookup(String) Lookup(String) Lookup(String) Lookup(String) Lookup(String) |
Retrieves the specified application setting. |
Remove(T) Remove(T) Remove(T) Remove(T) Remove(T) |
Removes the element with the specified key from the System.Collections.Generic.IDictionary`2. |
Remove(String) Remove(String) Remove(String) Remove(String) Remove(String) |
Removes the value with the specified key. |
TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) |
Gets the value associated with the specified key. |
Events
MapChanged MapChanged MapChanged MapChanged MapChanged |
Occurs when the map changes. |
See Also
- Quickstart: Local application data (JavaScript)
- Store and retrieve settings and other app data
- Quickstart: Roaming application data (JavaScript)
- Store and retrieve settings and other app data
- Store and retrieve settings and other app data
- ApplicationData
- ApplicationDataContainer
- ApplicationDataContainerSettings
- Application data sample
- Application data sample (Windows 10)