Exemplo n.º 1
0
 async Task <Settings> LoadSettingsInternal()
 {
     using (this.Bench()) {
         return(new Settings(
                    await _roamingCache.GetOrCreateObject("roamingSettings", () => new RoamingSettings()),
                    await _roamingSecureCache.GetOrCreateObject("secureSettings", () => new SecureSettings()),
                    await _localCache.GetOrCreateObject("localSettings", () => new LocalSettings())));
     }
 }
        public override async Task <bool> Migrate(List <Migration> migrations)
        {
            var key         = "____migration_version";
            var migrationId = await _cache.GetOrCreateObject(key, () => 0);

            var newMigrationId = migrations.Count;

            if (newMigrationId > migrationId)
            {
                foreach (var m in migrations.Skip(migrationId))
                {
                    await m.Migrate(this).ConfigureAwait(false);
                }
                // TODO: This should be a transaction :)
                await SaveChanges().ConfigureAwait(false);

                await _cache.InsertObject(key, newMigrationId);

                return(true);
            }
            return(false);
        }
 public IObservable <T> GetOrCreateObject <T>(string key, Func <T> createFunc)
 => _localCache.GetOrCreateObject(key, createFunc);