private IObservable <bool> ExecuteAdd( byte[] key, RedisTargetInfo targetInfo) { return(_dialogManager.Open(EditorDialogModel.AddHashItem(target => { return _clientAccessor.With(targetInfo, client => { var isValueEmpty = string.IsNullOrEmpty(target.Value); var isKeyEmpty = string.IsNullOrEmpty(target.Key); var isKeyDuplicate = !isKeyEmpty && client.Exists(target.Key); // TODO: async if (!isValueEmpty && !isKeyEmpty && !isKeyDuplicate) { client.HSet(ustring.Make(key).ToString(), target.Key, target.Value); } return new EditorResult { KeyError = isKeyEmpty ? "Key is empty" : (isKeyDuplicate ? "Key already exists" : null), ValueError = isValueEmpty ? "Value is empty" : null, Action = target.Action }; }); }))); }
private IObservable <bool> ExecuteAdd( byte[] key, RedisTargetInfo targetInfo) { return(_dialogManager.Open(EditorDialogModel.AddListItem(target => { return _clientAccessor.With(targetInfo, client => { var isValueEmpty = string.IsNullOrEmpty(target.Value); if (!isValueEmpty) { switch (target.Action) { case EditorAction.Prepend: client.LPush(ustring.Make(key).ToString(), target.Value); // TODO: async break; case EditorAction.Append: client.RPush(ustring.Make(key).ToString(), target.Value); // TODO: async break; } } return new EditorResult { ValueError = isValueEmpty ? "Value is empty" : null, Action = target.Action }; }); }))); }
//вернут результа из БД или ошибку из БД private IObservable <object> SaveCommand() { return(_dialogManager.Open(new ConfirmDialogModel { TitleText = "Изменить объект?", MessageText = "Вы желаете изменить объект?", ConfirmText = "Изменить", CancelText = "Отмена" }) .SelectMany(resultConfirmed => { if (!resultConfirmed) { return Observable.Return <object>(null); } else { return _repos.AddOrUpdate(_model.SelectedPhone) .ToObservable() .Select <Phone, object>(item => item != null ? new RxPhone(item) : null) .Catch <object, Exception>(except => Observable.Return(except)); } })); //return _repos.AddOrUpdate(_model.SelectedPhone).ToObservable() // .Select<Phone, object>(item => item != null ? new RxPhone(item) : null) // .Catch<object, Exception>(except => Observable.Return(except)); }
private IObservable <RedisConnectionInfo> Close() { return(_dialogManager.Open(new ConfirmDialogModel { TitleText = "Delete connection?", MessageText = "Do you want to delete selected connection?", ConfirmText = "Delete", CancelText = "Cancel" }) .SelectMany(confirmed => { if (!confirmed) { return Observable.Return <RedisConnectionInfo>(null); } return _connectionProvider.Close(_model.ConnectionInfo); })); }
public OptionsViewModel(ISettings settings, IDialogManager dialogs) { _options = new OptionsModel { LiveSensorData = settings.LiveSensorData, ConsoleFontSize = settings.ConsoleFontSize, LiveSensorHistory = settings.LiveSensorHistory, AutoSaveHistory = settings.AutoSaveHistory, AutoEvaluate = settings.AutoEvaluate, Accelerometer = settings.Accelerometer, Compass = settings.Compass, Gyrometer = settings.Gyrometer, Inclinometer = settings.Inclinometer, Light = settings.Light, Language = settings.Language }; _save = new RelayCommand(obj => { var window = obj as OptionsWindow; settings.LiveSensorData = _options.LiveSensorData; settings.ConsoleFontSize = _options.ConsoleFontSize; settings.LiveSensorHistory = _options.LiveSensorHistory; settings.AutoSaveHistory = _options.AutoSaveHistory; settings.AutoEvaluate = _options.AutoEvaluate; settings.Accelerometer = _options.Accelerometer; settings.Compass = _options.Compass; settings.Gyrometer = _options.Gyrometer; settings.Inclinometer = _options.Inclinometer; settings.Light = _options.Light; settings.Language = _options.Language; settings.Save(); if (window != null) { window.Close(); } }); _viewErrorLog = new RelayCommand(x => dialogs.Open(Dialog.Editor, Kernel.ErrorLog)); _viewLocalScript = new RelayCommand(x => dialogs.Open(Dialog.Editor, Kernel.LocalScript)); _viewGlobalScript = new RelayCommand(x => dialogs.Open(Dialog.Editor, Kernel.GlobalScript)); }
private IObservable <RedisConnectionInfo> Connect() { return(_dialogManager.Open(new ConnectDialogModel()) .Select(result => { if (result is ConnectResult.Created created) { return created.ConnectionInfo; } return null; })); }
private IObservable <bool> ExecuteAdd(byte[] key, RedisTargetInfo targetInfo) { return(_dialogManager.Open(EditorDialogModel.AddSetItem(target => { return _clientAccessor.With(targetInfo, client => { var isValueEmpty = string.IsNullOrEmpty(target.Value); var isValueDuplicate = !isValueEmpty && client.SIsMember(ustring.Make(key).ToString(), target.Value); if (!isValueEmpty && !isValueDuplicate) { client.SAdd(ustring.Make(key).ToString(), target.Value); } return new EditorResult { ValueError = isValueEmpty ? "Value is empty" : (isValueDuplicate ? "Value already exists" : null), Action = target.Action }; }); }))); }
private IObservable <DialogModelResult <RxPhone> > EditCommand() { //return _dialogManager.Open(new ConfirmDialogModel //{ // TitleText = "Изменить объект?", // MessageText = "Вы желаете изменить объект?", // ConfirmText = "Изменить", // CancelText = "Отмена" //}) // .SelectMany(confirmed => // { // if (!confirmed) // return Observable.Return<DialogModelResult<RxPhone>>(new DialogModelResult<RxPhone>.Cancelled()); // else // //откроем диалог Редактирования объекта // return _dialogManager.Open(new EditPhoneViewModel(_model.SelectedPhone)) // .Select(result => // { // var t = confirmed; // // можно варьировать предварительным результатом, например отслеживать ошибки // // if (result is EditPhoneViewModelResult.Edited edit) // // return edit; // // else return null; // return result; // }); // }); return(_dialogManager.Open(new EditPhoneViewModel(_model.SelectedPhone)) .Select(resultEdit => { // можно варьировать предварительным результатом, например отслеживать ошибки // if (result is EditPhoneViewModelResult.Edited edit) // return edit; // else return null; return resultEdit; })); }
private IObservable <bool> CheckLicense() { return(_licenseService.CheckCurrentLicenseAsync() .ToObservable() .SelectMany(isLicenseValid => { if (isLicenseValid) { return Observable.Return(true); } return _dialogManager.Open(new LicenseDialogModel()); }) .SelectMany(_ => _licenseService.CheckCurrentLicenseAsync())); }
public HelpViewModel(HelpSection entry, IDialogManager dialogs) { _help = entry; _icon = IconFactory.GetLowImage(entry.Topic); _show = new RelayCommand(x => dialogs.Open(Dialog.Help, _help)); }
private IObservable <ConnectResult> Connect() { return(_dialogManager.Open(new ConnectDialogModel())); }
private IObservable <Unit> OpenSettings() { return(_dialogManager.Open(new SettingsDialogModel())); }
private IObservable <bool> OpenDialog() { return(_dialogManager.Open(new LicenseDialogModel())); }