Updated ObjectStorage references in samples
This commit is contained in:
Родитель
be6555d9df
Коммит
d9e43fb4ed
|
@ -417,7 +417,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Controls
|
|||
/// <summary>
|
||||
/// The Local Storage Helper.
|
||||
/// </summary>
|
||||
private LocalObjectStorageHelper storage = new LocalObjectStorageHelper(new SystemSerializer());
|
||||
private ApplicationDataStorageHelper storage = ApplicationDataStorageHelper.GetCurrent(new Toolkit.Helpers.SystemSerializer());
|
||||
|
||||
/// <summary>
|
||||
/// DocFX note types and styling info, keyed by identifier.
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
|
||||
public static async void EnsureCacheLatest()
|
||||
{
|
||||
var settingsStorage = new LocalObjectStorageHelper(new SystemSerializer());
|
||||
var settingsStorage = ApplicationDataStorageHelper.GetCurrent(new Toolkit.Helpers.SystemSerializer());
|
||||
|
||||
var onlineDocsSHA = await GetDocsSHA();
|
||||
var cacheSHA = settingsStorage.Read<string>(_cacheSHAKey);
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
private static SemaphoreSlim _semaphore = new SemaphoreSlim(1);
|
||||
|
||||
private static LinkedList<Sample> _recentSamples;
|
||||
private static LocalObjectStorageHelper _localObjectStorageHelper = new LocalObjectStorageHelper(new SystemSerializer());
|
||||
private static ApplicationDataStorageHelper _localObjectStorageHelper = ApplicationDataStorageHelper.GetCurrent(new Toolkit.Helpers.SystemSerializer());
|
||||
|
||||
public static async Task<SampleCategory> GetCategoryBySample(Sample sample)
|
||||
{
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
var localObjectStorageHelper = new LocalObjectStorageHelper();
|
||||
var roamingObjectStorageHelper = new RoamingObjectStorageHelper();
|
||||
ApplicationDataStorageHelper appDataStorageHelper = ApplicationDataStorageHelper.GetCurrent(new Toolkit.Helpers.SystemSerializer());
|
||||
|
||||
// Read and Save with simple objects
|
||||
string keySimpleObject = "simple";
|
||||
string result = localObjectStorageHelper.Read<string>(keySimpleObject);
|
||||
localObjectStorageHelper.Save(keySimpleObject, 47);
|
||||
string result = appDataStorageHelper.Read<string>(keySimpleObject);
|
||||
appDataStorageHelper.Save(keySimpleObject, 47);
|
||||
|
||||
// Read and Save with complex/large objects
|
||||
string keyLargeObject = "large";
|
||||
var result = localObjectStorageHelper.ReadFileAsync<MyLargeObject>(keyLargeObject);
|
||||
string complexObjectKey = "complexObject";
|
||||
var complexObject = await appDataStorageHelper.ReadFileAsync<MyLargeObject>(complexObjectKey);
|
||||
|
||||
var o = new MyLargeObject
|
||||
var myComplexObject = new MyComplexObject()
|
||||
{
|
||||
...
|
||||
};
|
||||
localObjectStorageHelper.SaveFileAsync(keySimpleObject, o);
|
||||
await appDataStorageHelper.SaveFileAsync(complexObjectKey, myComplexObject);
|
||||
|
||||
// Complex object
|
||||
public class MyLargeObject
|
||||
public class MyComplexObject
|
||||
{
|
||||
public string MyContent { get; set; }
|
||||
public List<string> MyContents { get; set; }
|
||||
public List<MyLargeObject> MyObjects { get; set; }
|
||||
public List<MyComplexObject> MyObjects { get; set; }
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Toolkit.Helpers;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
|
@ -9,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
{
|
||||
public sealed partial class ObjectStoragePage
|
||||
{
|
||||
private readonly IObjectStorageHelper localStorageHelper = new LocalObjectStorageHelper(new SystemSerializer());
|
||||
private readonly ISettingsStorageHelper localStorageHelper = ApplicationDataStorageHelper.GetCurrent(new Toolkit.Helpers.SystemSerializer());
|
||||
|
||||
public ObjectStoragePage()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче