public ConnectionEditorViewModel(ExplicitConnection explicitConnection, Action <ConnectionEditorViewModel> saveHandler, Action cancelHandler) { if (saveHandler == null) { throw new ArgumentNullException(nameof(saveHandler)); } if (cancelHandler == null) { throw new ArgumentNullException(nameof(cancelHandler)); } SaveCommand = new Command(_ => saveHandler(this)); CancelCommand = new Command(_ => cancelHandler()); ExploreToSettingsFileCommand = new Command(_ => ExploreToSettingsFile()); if (explicitConnection == null) { return; } Id = explicitConnection.Id; _label = explicitConnection.Label; _host = explicitConnection.Host; _authorisationKey = explicitConnection.AuthorisationKey; _databaseId = explicitConnection.DatabaseId; _collectionId = explicitConnection.CollectionId; }
private void SaveConnection(ConnectionEditorViewModel viewModel) { var connection = new ExplicitConnection(viewModel.Id.GetValueOrDefault(Guid.NewGuid()), viewModel.Label, viewModel.Host, viewModel.AuthorisationKey, viewModel.DatabaseId, viewModel.CollectionId); _explicitConnectionCache.AddOrUpdate(connection); Mode = ConnectionsManagerMode.Selector; }
private void SaveHandler(ConnectionEditorViewModel connectionEditorViewModel, DialogSession dialogSession) { var connection = new ExplicitConnection(connectionEditorViewModel.Id.GetValueOrDefault(Guid.NewGuid()), connectionEditorViewModel.Label, connectionEditorViewModel.Host, connectionEditorViewModel.AuthorisationKey, connectionEditorViewModel.DatabaseId, connectionEditorViewModel.CollectionId); _explicitConnectionCache.AddOrUpdate(connection); dialogSession.Close(connection); }
private static JObject ToJson(ExplicitConnection explicitConnection) { dynamic cn = new JObject(); cn.id = explicitConnection.Id; cn.label = explicitConnection.Label; cn.host = explicitConnection.Host; cn.authorisationKey = explicitConnection.AuthorisationKey; cn.databaseId = explicitConnection.DatabaseId; cn.collectionId = explicitConnection.CollectionId; return(cn); }
protected bool Equals(ExplicitConnection other) { return(Id.Equals(other.Id)); }
public void AddOrUpdate(ExplicitConnection explicitConnection) { _connectionSoureCache.AddOrUpdate(explicitConnection); }