32 lines
853 B
C#
32 lines
853 B
C#
using System;
|
|
using System.Reactive;
|
|
using Akavache;
|
|
using ReactiveUI;
|
|
|
|
namespace Intromat
|
|
{
|
|
public class AkavacheSuspensionDriver<TAppState> : ISuspensionDriver where TAppState : class
|
|
{
|
|
private const string AppStateKey = "appState";
|
|
|
|
public AkavacheSuspensionDriver()
|
|
{
|
|
BlobCache.ApplicationName = "Your Application Name";
|
|
}
|
|
|
|
public IObservable<Unit> InvalidateState()
|
|
{
|
|
return BlobCache.UserAccount.InvalidateObject<TAppState>(AppStateKey);
|
|
}
|
|
|
|
public IObservable<object> LoadState()
|
|
{
|
|
return BlobCache.UserAccount.GetObject<TAppState>(AppStateKey)!;
|
|
}
|
|
|
|
public IObservable<Unit> SaveState(object state)
|
|
{
|
|
return BlobCache.UserAccount.InsertObject(AppStateKey, (TAppState)state);
|
|
}
|
|
}
|
|
} |