public ConnectedAccountViewModel(ConnectedAccount ca) : base(ca, null) { _ca = ca ?? throw new System.ArgumentNullException(nameof(ca)); Tag = ca; AddActionCommands(ca); CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Edit", Symbol.Edit, EditAccountCommand))); HierarchicalResourceCommandGroup copyGroup = AddCommandGroup( new HierarchicalResourceCommand("copy connection string", Symbol.Copy, () => { ServiceLocator.SystemService.SetClipboardText(_ca.ConnectionString); return(Task.CompletedTask); })); if (_ca.StorageConnectionString.Parameters.TryGetValue(KnownParameter.KeyOrPassword, out string keyOrPassword)) { copyGroup.Commands.Add(new HierarchicalResourceCommand("copy key/password", Symbol.Copy, () => { ServiceLocator.SystemService.SetClipboardText(keyOrPassword); return(Task.CompletedTask); })); } }
private async Task GetSharedKeyAsync() { IReadOnlyList <StorageAccountKey> keys = await _storageAccount.GetKeysAsync(); if (keys?.Count == 0) { return; } _primarySharedKey = keys[0].Value; _secondarySharedKey = keys[1].Value; CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Copy primary key", Symbol.Copy, () => { ServiceLocator.SystemService.SetClipboardText(_primarySharedKey); return(Task.CompletedTask); }), new HierarchicalResourceCommand("Copy secondary key", Symbol.Copy, () => { ServiceLocator.SystemService.SetClipboardText(_secondarySharedKey); return(Task.CompletedTask); } ))); foreach (HierarchicalResource child in Children) { if (child is AzureStorageSubAccount sa) { sa.PrimarySharedKey = _primarySharedKey; sa.SecondarySharedKey = _secondarySharedKey; } } }
public ConnectedFolderViewModel(ConnectedFolder cf) : base(cf, "folder2") { CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Add subfolder", Symbol.NewFolder, AddSubfolderAsync), new HierarchicalResourceCommand("Add Account...", Symbol.Account, () => AppDialogs.ShowConnectedAccountDialogAsync(cf, null)))); Folder = cf; }
public HierarchicalResource(string name = null, string iconPath = null, bool useBuiltInCommands = true) { if (name != null) { DisplayName = name; } IconPath = iconPath; IsVisible = true; if (useBuiltInCommands) { CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Copy name", Symbol.Copy, () => { ServiceLocator.SystemService.SetClipboardText(DisplayName); return(Task.CompletedTask); }), new HierarchicalResourceCommand("expand all", Symbol.Upload, () => { this.SetExpandedRecursively(true); return(Task.CompletedTask); }), new HierarchicalResourceCommand("collapse all", Symbol.Download, () => { this.SetExpandedRecursively(false); return(Task.CompletedTask); }))); } }
public CommandCollection(bool usePluralForms, IEnumerable <CommandBase> commands) { // Use plural commands if required var pluralCommands = usePluralForms ? ToPlural(commands) : commands; var groups = pluralCommands .GroupBy(c => c.GetType()) .Select(g => (att: GetAttribute(g.Key), group: g)) // Sort each type .OrderBy(t => t.att.Order) .Select(t => new CommandGroup( t.group.Key, t.att.HeaderComment, // Sort commands within type t.group.OrderBy(c => c.SortIndex).ToImmutableArray())) .ToImmutableArray(); CommandGroups = groups; AllCommands = CommandGroups .SelectMany(g => g.Commands) .ToImmutableArray(); DataLossCommands = CommandGroups .Where(g => g.CommandType == typeof(DropTableCommand) || g.CommandType == typeof(DropTableColumnsCommand) || g.CommandType == typeof(AlterColumnTypeCommand)) .SelectMany(g => g.Commands) .ToImmutableArray(); }
public AzureSubscription(IAuthenticated authenticated, ISubscription subscription) : base(subscription.DisplayName, "azure/subscription") { _azure = authenticated.WithSubscription(subscription.SubscriptionId); CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("refresh", Symbol.Refresh, RefreshAsync))); RefreshAsync().Forget(); }
public AwsS3Bucket(string name, string cliProfileName, string region) : base(name, "account/aws.s3") { _cliProfileName = cliProfileName; _region = region; CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Attach", Symbol.Attach, AttachCommand), new HierarchicalResourceCommand("Properties", Symbol.Setting, ShowPropertiesCommand))); }
public ConnectedEntitiesViewModel() : base("Accounts", "paperclip") { IsExpanded = true; Children = ToHR(ConnectedAccount.RootFolder.Children); CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Add account", Symbol.Account, () => AppDialogs.ShowConnectedAccountDialogAsync(null, null)), new HierarchicalResourceCommand("Add folder", Symbol.NewFolder, AddRootFolderAsync))); }
public AwsCliProfile(string name, AWSCredentials nativeCredentials) : base(name, "cloud-aws-profile") { CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Discover resources", Symbol.Refresh, RefreshCommand), new HierarchicalResourceCommand("Properties", Symbol.Setting, PropertiesCommand))); NativeCredentials = nativeCredentials; DiscoverAsync().Forget(); }
public AzureAccount(ConnectedAzureAccount connectedAzureAccount) : base(connectedAzureAccount.DisplayName, "azure/directory") { _client = MultiTenantAzure.FromAccount(connectedAzureAccount); CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("refresh", Symbol.Refresh, RefreshAsync), new HierarchicalResourceCommand("delete", Symbol.Delete, DeleteAsync))); RefreshAsync().Forget(); _connectedAzureAccount = connectedAzureAccount; }
public AmazonAws() : base("Amazon AWS", "cloud-aws") { IsExpanded = false; Children.Add(_awsCliProfiles); RefreshAwsCliProfiles(); CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("Refresh", Symbol.Refresh, RefreshCliProfilesCommand))); }
public MicrosoftAzure() : base("Microsoft Azure", "azure/logo") { IsExpanded = true; CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("add new account", Symbol.Add, AddAzureAccountAsync))); Children = new SynchronisedObservableCollection <HierarchicalResource, ConnectedAzureAccount>( ConnectedAccount.AzureAccounts, caa => new AzureAccount(caa)); }
public ConnectedEntityViewModel(ConnectedEntity connectedEntity, string iconPath) : base(connectedEntity.DisplayName, iconPath) { IsExpanded = true; CommandGroups.Add(new HierarchicalResourceCommandGroup( new HierarchicalResourceCommand("delete", Symbol.Delete, DeleteAsync), new HierarchicalResourceCommand("rename", Symbol.Rename, RenameAsync) )); connectedEntity.PropertyChanged += _ca_PropertyChanged; _connectedEntity = connectedEntity; }
private void AddActionCommands(ConnectedAccount ca) { if (!(ca.Definition is BlobApplicationAccount baa)) { return; } IReadOnlyCollection <ActionGroup> actionGroups = baa.GetExecutableAccountActionGroups(ca); foreach (ActionGroup ag in actionGroups) { var hrg = new HierarchicalResourceCommandGroup( ag.Actions.Select( cmd => new HierarchicalResourceCommand(cmd.Name, cmd.Icon, () => cmd.ExecuteAsync(ca, null))).ToArray() ); CommandGroups.Add(hrg); } }
public HystrixCommandOptions GetCommandOptions(string groupKey, string commandKey) { if (CommandGroups == null) { return(DefaultOptions ?? HystrixCommandOptions.CreateDefault()); } if (!CommandGroups.TryGetValue(groupKey, out var groupCommands)) { return(DefaultOptions ?? HystrixCommandOptions.CreateDefault()); } if (!groupCommands.TryGetValue(commandKey, out var commandOptions)) { return(DefaultOptions ?? HystrixCommandOptions.CreateDefault()); } return(commandOptions); }