Esempio n. 1
0
        public HostNode(
            GroupedConnection groupedConnection,
            IManagementActionsController managementActionsController,
            IExplicitConnectionCache explicitConnectionCache,
            IImplicitConnectionCache implicitConnectionCache,
            DispatcherScheduler dispatcherScheduler
            )
        {
            if (groupedConnection == null)
            {
                throw new ArgumentNullException(nameof(groupedConnection));
            }
            if (managementActionsController == null)
            {
                throw new ArgumentNullException(nameof(managementActionsController));
            }
            if (groupedConnection.Key.Level != GroupedConnectionKeyLevel.AuthorisationKey)
            {
                throw new ArgumentException($"Expected key level of {GroupedConnectionKeyLevel.AuthorisationKey}.", nameof(groupedConnection));
            }

            Host             = groupedConnection[GroupedConnectionKeyLevel.Host];
            AuthorisationKey = groupedConnection[GroupedConnectionKeyLevel.AuthorisationKey];
            var authKeyHint = AuthorisationKey ?? "";

            AuthorisationKeyHint =
                (authKeyHint.Length > 0 ? authKeyHint.Substring(0, Math.Min(authKeyHint.Length, 5)) : "")
                + "...";

            CreateDatabaseCommand = new Command(_ => managementActionsController.AddDatabase(this));

            ReadOnlyObservableCollection <DatabaseNode> nodes;

            _disposable = explicitConnectionCache.BuildChildNodes(
                implicitConnectionCache,
                groupedConnection.Key,
                GroupedConnectionKeyLevel.DatabaseId,
                groupedCn =>
                new DatabaseNode(this, groupedCn, managementActionsController, explicitConnectionCache,
                                 implicitConnectionCache, dispatcherScheduler),
                DatabaseSortComparer,
                dispatcherScheduler, out nodes);
            Databases = nodes;
        }
Esempio n. 2
0
        public DatabaseNode(HostNode owner, GroupedConnection groupedConnection, IManagementActionsController managementActionsController, IExplicitConnectionCache explicitConnectionCache, IImplicitConnectionCache implicitConnectionCache, DispatcherScheduler dispatcherScheduler)
        {
            Owner = owner;
            ReadOnlyObservableCollection <CollectionNode> nodes;

            _disposable = explicitConnectionCache.BuildChildNodes(
                implicitConnectionCache,
                groupedConnection.Key,
                GroupedConnectionKeyLevel.CollectionId,
                groupedCn =>
                new CollectionNode(this, groupedCn[GroupedConnectionKeyLevel.CollectionId], managementActionsController),
                CollectionSortComparer,
                dispatcherScheduler,
                out nodes);
            Collections = nodes;

            DatabaseId = groupedConnection[GroupedConnectionKeyLevel.DatabaseId];

            CreateCollectionCommand = new Command(_ => managementActionsController.AddCollection(this));
            DeleteDatabaseCommand   = new Command(_ => managementActionsController.DeleteDatabase(this));
        }