예제 #1
0
 public static IDisposable BuildChildNodes <TNode>(
     this IExplicitConnectionCache explicitConnectionCache,
     IImplicitConnectionCache implicitConnectionCache,
     GroupedConnectionKey parentKey,
     GroupedConnectionKeyLevel childKeyLevel,
     Func <GroupedConnection, TNode> childNodeFactory,
     IComparer <TNode> sortComparer,
     IScheduler scheduler,
     out ReadOnlyObservableCollection <TNode> nodes)
 {
     return(explicitConnectionCache.Connect()
            //user could dupe the connections, so we group em all
            .Filter(FilterBuilder <ExplicitConnection>(parentKey))
            .Group(explicitCn => new GroupedConnectionKey(explicitCn, childKeyLevel))
            .FullJoin(
                implicitConnectionCache.Connect()
                .Filter(FilterBuilder <ImplicitConnection>(parentKey))
                .Group(
                    implicitCn =>
                    new GroupedConnectionKey(implicitCn, childKeyLevel)),
                implicitGroup => implicitGroup.Key,
                (key, left, right) =>
                new GroupedConnection(key, left.GetOptionalConnections(), right.GetOptionalConnections()))
            .Filter(gc => !string.IsNullOrEmpty(gc[childKeyLevel]))
            .Transform(childNodeFactory)
            .DisposeMany()
            .Sort(sortComparer)
            .ObserveOn(scheduler)
            .Bind(out nodes)
            .Subscribe());
 }
예제 #2
0
        public LocalEmulatorDetector(IImplicitConnectionCache implicitConnectionCache)
        {
            if (implicitConnectionCache == null)
            {
                throw new ArgumentNullException(nameof(implicitConnectionCache));
            }

            _observable = Observable
                          .Timer(TimeSpan.FromMilliseconds(1500), TimeSpan.FromSeconds(3))
                          .Select(_ => SafeGetConnections())
                          .Publish()
                          .RefCount();
        }
예제 #3
0
파일: HostNode.cs 프로젝트: th851dan/doobry
        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;
        }
예제 #4
0
        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;
        }
예제 #5
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));
        }
예제 #6
0
 public static IDisposable MergeConnectionsIntoCache(
     IObservable <LocalEmulatorDetectorUnit> detectorUnitObservable,
     IImplicitConnectionCache implicitConnectionCache)
 {
     return(detectorUnitObservable.Subscribe(unit => implicitConnectionCache.Merge("LocalEmulator", unit.Connections)));
 }