diff --git a/en-us/TOC.md b/en-us/TOC.md index 825a9f3..37e4d53 100644 --- a/en-us/TOC.md +++ b/en-us/TOC.md @@ -45,7 +45,7 @@ lang: en-us - [Streams]({{site.baseurl}}/{{page.lang}}/helpers/streams.htm) - [VisualTreeExtensions]({{site.baseurl}}/{{page.lang}}/helpers/visualtreeextensions.htm) - [WeakEventListener]({{site.baseurl}}/{{page.lang}}/helpers/weakeventlistener.htm) - +- [Storage]({{site.baseurl}}/{{page.lang}}/helpers/storage.htm) # Notifications diff --git a/en-us/codehelpers.md b/en-us/codehelpers.md index 413815e..5a789c3 100644 --- a/en-us/codehelpers.md +++ b/en-us/codehelpers.md @@ -22,7 +22,7 @@ Click the links below to go directly to that namespace in the online API. | [Streams]({{site.baseurl}}/{{page.lang}}/helpers/streams.htm) | Helpers for processing stream data from APPX or Internet | | [VisualTreeExtensions]({{site.baseurl}}/{{page.lang}}/helpers/visualtreeextensions.htm) | Provides a collection of extensions methods for UI | | [WeakEventListener]({{site.baseurl}}/{{page.lang}}/helpers/weakeventlistener.htm) | Allows the owner to be garbage collected if its only remaining link is an event handler | - +| [Storage]({{site.baseurl}}/{{page.lang}}/helpers/storage.htm) | Helpers to save and retrieve generic objects easily, supports both local and roaming storage | ## Getting Started diff --git a/en-us/helpers/storage.md b/en-us/helpers/storage.md new file mode 100644 index 0000000..b8667bd --- /dev/null +++ b/en-us/helpers/storage.md @@ -0,0 +1,54 @@ +--- +permalink: /en-US/helpers/storage.htm +title: StorageService +description: Service that will help you handle storage of generic objects within UWP applications, both locally and across all devices (roaming) +keywords: windows, app, toolkit, UWP, helpers, storage, save, read, generic objects +layout: api +search.product: eADQiWindows 10XVcnh +lang: en-us +--- + +## StorageService + +The StorageService is a service that will help you handle storage of generic objects within UWP applications, both locally and across all devices (roaming). + +## Example + +{% highlight csharp %} + + var localStorageService = new LocalStorageService(); + var roamingStorageService = new RoamingStorageService(); + + // Read and Save with simple objects + string keySimpleObject = "simple"; + string result = localStorageService.Read(keySimpleObject); + localStorageService.Save(keySimpleObject, 47); + + // Read and Save with complex/large objects + string keyLargeObject = "large"; + var result = localStorageService.ReadFileAsync(keyLargeObject); + + var o = new MyLargeObject + { + ... + }; + localStorageService.SaveFileAsync(keySimpleObject, o); + + // Complex object + public class MyLargeObject + { + public string MyContent { get; set; } + public List MyContents { get; set; } + public List MyObjects { get; set; } + } + +{% endhighlight %} + +## Requirements (Windows 10 Device Family) + +| [Device family](http://go.microsoft.com/fwlink/p/?LinkID=526370) | Universal, 10.0.10586.0 or higher | +| Namespace | Microsoft.Toolkit.Uwp | + +## API +* [StorageService source code](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp/Helpers/Storage/StorageService.cs) +* [StorageService API documentation]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_StorageService.htm)