async public Task InitAsync() { structure = await api.GetAsync(); if (structure == null) { throw new Exception("Structure could not be fetched from API!"); } }
public async Task InitAsync() { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(RESOURCE_FILE)) using (StreamReader reader = new StreamReader(stream)) { string json = reader.ReadToEnd(); structure = JsonConvert.DeserializeObject <DpsgStructure>(json); } }
private async Task <DpsgStructure> GetRemoteAsync() { string path = ObjectName(); HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); DpsgStructure structure = JsonConvert.DeserializeObject <DpsgStructure>(json); return(structure); } return(null); }
public async Task <DpsgStructure> GetAsync() { DpsgStructure result = null; string key = ObjectName(); var cache = BlobCache.LocalMachine; var cachedPromise = cache.GetAndFetchLatest( key, () => GetRemoteAsync() ); cachedPromise.Subscribe(subscribedStructure => { Debug.WriteLine("Subscribed Object ready"); result = subscribedStructure; }); result = await cachedPromise.FirstOrDefaultAsync(); return(result); }