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; }
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)); }
public ManagementViewModel( IExplicitConnectionCache explicitConnectionCache, IImplicitConnectionCache implicitConnectionCache, IManagementActionsController managementActionsController, DispatcherScheduler dispatcherScheduler) { if (explicitConnectionCache == null) { throw new ArgumentNullException(nameof(explicitConnectionCache)); } if (implicitConnectionCache == null) { throw new ArgumentNullException(nameof(implicitConnectionCache)); } if (managementActionsController == null) { throw new ArgumentNullException(nameof(managementActionsController)); } if (dispatcherScheduler == null) { throw new ArgumentNullException(nameof(dispatcherScheduler)); } Name = "DB Manager"; ReadOnlyObservableCollection <HostNode> nodes; _disposable = explicitConnectionCache.BuildChildNodes( implicitConnectionCache, null, GroupedConnectionKeyLevel.AuthorisationKey, groupedConnection => new HostNode(groupedConnection, managementActionsController, explicitConnectionCache, implicitConnectionCache, dispatcherScheduler), HostSortComparer, dispatcherScheduler, out nodes); Hosts = nodes; }