コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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);
        }