コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: Serializer.cs プロジェクト: th851dan/doobry
        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);
        }
コード例 #5
0
 protected bool Equals(ExplicitConnection other)
 {
     return(Id.Equals(other.Id));
 }
コード例 #6
0
 public void AddOrUpdate(ExplicitConnection explicitConnection)
 {
     _connectionSoureCache.AddOrUpdate(explicitConnection);
 }