public (ICommand, string) GenerateCommand(string metaColumn, DatabaseEntity entity, DatabaseKey realKey) { if (metaColumn.StartsWith("table:")) { var parts = metaColumn.Substring(6).Split(';'); if (parts.Length < 2) { throw new NotSupportedException("Invalid table meta column: " + metaColumn + ". Expected `table:<tableName>;<condition>(;<keys>)?`"); } var table = parts[0]; var condition = parts[1]; var keyParts = parts.Length == 3 ? parts[2].Split(',') : new string[] {}; return(new DelegateCommand( () => { var newCondition = entity.FillTemplate(condition); tableEditorPickerService.ShowTable(table, newCondition, keyParts.Length == 0 ? null : new DatabaseKey(keyParts.Select(entity.GetTypedValueOrThrow <long>))).ListenErrors(); }), "Open"); } if (metaColumn.StartsWith("tableByKey:")) { var table = metaColumn.Substring(11, metaColumn.IndexOf(";") - 11); var key = metaColumn.Substring(metaColumn.IndexOf(";") + 1); return(new DelegateCommand(() => { tableEditorPickerService.ShowTable(table, null, new DatabaseKey(entity.GetTypedValueOrThrow <long>(key))).ListenErrors(); }), "Open"); } if (metaColumn.StartsWith("one2one:")) { var table = metaColumn.Substring(8); return(new DelegateCommand( () => { tableEditorPickerService.ShowForeignKey1To1(table, entity.Key).ListenErrors(); }, () => !entity.Phantom), "Open"); } if (metaColumn.StartsWith("invoke:")) { var command = metaColumn.Substring(7); return(new AsyncAutoCommand( () => { var result = entity.FillTemplate(command); return remoteConnectorService.ExecuteCommand(new AnonymousRemoteCommand(result)); }, () => !entity.Phantom), "Invoke"); } return(new AlwaysDisabledCommand(), "(invalid)"); }