public static async Task <CapabilityDiscoveryResult> GetDiscoveryCapabilityResultAsync(string capability) { var cacheResult = await DiscoveryServiceCache.LoadAsync(); CapabilityDiscoveryResult discoveryCapabilityResult = null; if (cacheResult != null && cacheResult.DiscoveryInfoForServices.ContainsKey(capability)) { discoveryCapabilityResult = cacheResult.DiscoveryInfoForServices[capability]; var initialAuthResult = await GetAccessTokenAsync(discoveryCapabilityResult.ServiceResourceId); if (initialAuthResult.UserInfo.UniqueId != cacheResult.UserId) { // cache is for another user cacheResult = null; } } if (cacheResult == null) { cacheResult = await CreateAndSaveDiscoveryServiceCacheAsync(); discoveryCapabilityResult = cacheResult.DiscoveryInfoForServices[capability]; } return(discoveryCapabilityResult); }
public static async Task <IDictionary <string, CapabilityDiscoveryResult> > GetAllCapabilityDiscoveryResultAsync() { DiscoveryServiceCache discoveryCache = null; var cacheResult = await DiscoveryServiceCache.LoadAsync(); if (cacheResult == null) { discoveryCache = await CreateAndSaveDiscoveryServiceCacheAsync(); return(discoveryCache.DiscoveryInfoForServices); } return(cacheResult.DiscoveryInfoForServices); }
public static async Task <CapabilityDiscoveryResult> GetCapabilityDiscoveryResultAsync(ServiceCapabilities serviceCapability) { var discoveryServiceInfo = await GetAllCapabilityDiscoveryResultAsync(); DiscoveryServiceCache discoveryCache = null; var cacheResult = await DiscoveryServiceCache.LoadAsync(serviceCapability); if (cacheResult == null) { discoveryCache = await CreateAndSaveDiscoveryServiceCacheAsync(); CapabilityDiscoveryResult capabilityDiscoveryResult = null; discoveryCache.DiscoveryInfoForServices.TryGetValue(serviceCapability.ToString(), out capabilityDiscoveryResult); return(capabilityDiscoveryResult); } else { return(cacheResult.CapabilityResult); } }