This repository has been archived by the owner on Jul 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Odonno/storageService
docs(storage): add storage service documentation
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string>(keySimpleObject); | ||
localStorageService.Save(keySimpleObject, 47); | ||
|
||
// Read and Save with complex/large objects | ||
string keyLargeObject = "large"; | ||
var result = localStorageService.ReadFileAsync<MyLargeObject>(keyLargeObject); | ||
|
||
var o = new MyLargeObject | ||
{ | ||
... | ||
}; | ||
localStorageService.SaveFileAsync(keySimpleObject, o); | ||
|
||
// Complex object | ||
public class MyLargeObject | ||
{ | ||
public string MyContent { get; set; } | ||
public List<string> MyContents { get; set; } | ||
public List<MyLargeObject> 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) |