public CollectionNode(DatabaseNode owner, string collectionId, IManagementActionsController managementActionsController) { Owner = owner; CollectionId = collectionId; DeleteCollectionCommand = new Command(_ => managementActionsController.DeleteCollection(this)); }
public static IDisposable LaunchGettingStarted( IObservable <LocalEmulatorDetectorUnit> detectorUnitObservable, ISnackbarMessageQueue snackbarMessageQueue, IManagementActionsController managementActionsController, IExplicitConnectionCache explicitConnectionCache) { return(detectorUnitObservable .Select(u => u.IsRunnng && u.Connections.All(cn => cn.DatabaseId == null && cn.CollectionId == null)) .StartWith(false) .DistinctUntilChanged() .Where( isLocalEmulatorRunningWithoutDatabasesAndCollections => isLocalEmulatorRunningWithoutDatabasesAndCollections) .Subscribe( _ => snackbarMessageQueue.Enqueue("Local Emulator Detected", "GET STARTED", async() => await RunGetStarted(managementActionsController, explicitConnectionCache)))); }
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; }
private static async Task RunGetStarted(IManagementActionsController managementActionsController, IExplicitConnectionCache explicitConnectionCache) { var addDatabaseResult = await managementActionsController.AddDatabase(LocalEmulator.Host, LocalEmulator.AuthorisationKey); if (!addDatabaseResult.IsCompleted) { return; } var addCollectionResult = await managementActionsController.AddCollection(LocalEmulator.Host, LocalEmulator.AuthorisationKey, addDatabaseResult.ItemId); if (!addCollectionResult.IsCompleted) { return; } var explicitConnection = new ExplicitConnection(Guid.NewGuid(), $"localhost:{addDatabaseResult.ItemId}/{addCollectionResult.ItemId}", LocalEmulator.Host, LocalEmulator.AuthorisationKey, addDatabaseResult.ItemId, addCollectionResult.ItemId); explicitConnectionCache.AddOrUpdate(explicitConnection); }
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; }