private async Task RefreshAsync() { EventLog.LogEvent("refreshAzureSubscription", "name: {name}", DisplayName); IsLoading = true; Children.Clear(); try { IPagedCollection <IStorageAccount> accounts = await _azure.StorageAccounts.ListAsync(); foreach (IStorageAccount sa in accounts) { if (GlobalSettings.Default.AzureGroupResourcesByResourceGroup) { AzureResourceGroup rg = GetOrCreateResourceGroup(sa.ResourceGroupName); rg.Children.Add(new AzureStorageAccount(sa)); } else { Children.Add(new AzureStorageAccount(sa)); } } } catch (Exception ex) { Error = ex; } finally { IsLoading = false; } }
private AzureResourceGroup GetOrCreateResourceGroup(string name) { if (_resourceGroups.TryGetValue(name, out AzureResourceGroup rg)) { return(rg); } rg = new AzureResourceGroup(name); _resourceGroups[name] = rg; Children.Add(rg); return(rg); }