private void InitializeBindings()
        {
            LogViewsSourceCache.Connect()
            .AutoRefresh(logView => logView.IsOpen)
            .Filter(logView => logView.IsOpen)
            .ObserveOnDispatcher()
            .Bind(out _openLogViews)
            .DisposeMany()
            .Subscribe();
            LogViewsSourceCache.Connect()
            .AutoRefresh(logView => logView.IsEdited)
            .Filter(logView => logView.IsEdited)
            .ObserveOnDispatcher()
            .Bind(out _unsavedLogViews)
            .DisposeMany()
            .Subscribe();

            AvailableUsernamesSourceCache.Connect()
            .ObserveOnDispatcher()
            .Bind(out _availableUsernames)
            .DisposeMany()
            .Subscribe();
            AvailableComputernamesSourceCache.Connect()
            .ObserveOnDispatcher()
            .Bind(out _availableComputernames)
            .DisposeMany()
            .Subscribe();
        }
Esempio n. 2
0
        private void InitializeBindings()
        {
            #region Log views
            var logViewsSharedSource = LogViewsSourceCache.Connect();
            logViewsSharedSource
            .AutoRefresh(l => l.DateLastOpened)
            .Sort(SortExpressionComparer <LogView> .Descending(l => l.DateLastOpened))
            .ObserveOnDispatcher()
            .Bind(out var logViews)
            .Subscribe();
            logViewsSharedSource
            .AutoRefresh(l => l.DateLastOpened)
            .Sort(SortExpressionComparer <LogView> .Descending(l => l.DateLastOpened))
            .Top(_numberInRecents)
            .ObserveOnDispatcher()
            .Bind(out var recentlyUsedLogViews)
            .Subscribe();
            logViewsSharedSource
            .AutoRefresh(l => l.DateLastOpened)
            .AutoRefresh(l => l.IsPinned)
            .Filter(l => l.IsPinned)
            .Sort(SortExpressionComparer <LogView> .Descending(l => l.DateLastOpened))
            .ObserveOnDispatcher()
            .Bind(out var pinnedLogViews)
            .Subscribe();

            LogViews             = logViews;
            RecentlyUsedLogViews = recentlyUsedLogViews;
            PinnedLogViews       = pinnedLogViews;
            #endregion

            #region Log files
            var logFilesSharedSource = LogFilesSourceCache.Connect();

            logFilesSharedSource
            .AutoRefresh(l => l.DateLastOpened)
            .Sort(SortExpressionComparer <LogFile> .Descending(l => l.DateLastOpened))
            .ObserveOnDispatcher()
            .Bind(out var allLogFiles)
            .Subscribe();
            logFilesSharedSource
            .AutoRefresh(l => l.DateLastOpened)
            .Sort(SortExpressionComparer <LogFile> .Descending(l => l.DateLastOpened))
            .Top(_numberInRecents)
            .ObserveOnDispatcher()
            .Bind(out var recentlyUsedLogFiles)
            .Subscribe();
            logFilesSharedSource
            .AutoRefresh(l => l.IsPinned)
            .AutoRefresh(l => l.DateLastOpened)
            .Filter(l => l.IsPinned)
            .Sort(SortExpressionComparer <LogFile> .Descending(l => l.DateLastOpened))
            .ObserveOnDispatcher()
            .Bind(out var pinnedLogFiles)
            .Subscribe();

            LogFiles             = allLogFiles;
            RecentlyUsedLogFiles = recentlyUsedLogFiles;
            PinnedLogFiles       = pinnedLogFiles;
            #endregion

            #region Databases
            var databasesSharedSource = DatabasesSourceCache.Connect();

            databasesSharedSource
            .ObserveOnDispatcher()
            .Bind(out var databases)
            .Subscribe();
            databasesSharedSource
            .AutoRefresh(d => d.DateLastOpened)
            .Sort(SortExpressionComparer <Database> .Descending(d => d.DateLastOpened))
            .Top(_numberInRecents)
            .ObserveOnDispatcher()
            .Bind(out var recentlyUsedDatabases)
            .Subscribe();
            databasesSharedSource
            .AutoRefresh(l => l.IsPinned)
            .AutoRefresh(d => d.DateLastOpened)
            .Filter(l => l.IsPinned)
            .Sort(SortExpressionComparer <Database> .Descending(d => d.DateLastOpened))
            .ObserveOnDispatcher()
            .Bind(out var pinnedDatabases)
            .Subscribe();

            Databases             = databases;
            RecentlyUsedDatabases = recentlyUsedDatabases;
            PinnedDatabases       = pinnedDatabases;
            #endregion

            #region Searchable openable objects
            //TODO: Right now if item added to source caches, this source cache won't see it. Maybe do a join?
            //TODO: Need to open search popup when user clicks on search box if there's text in the search box.
            AllOpenableObjectsSourceCache.AddOrUpdate(LogViewsSourceCache.Items);
            AllOpenableObjectsSourceCache.AddOrUpdate(LogFilesSourceCache.Items);
            AllOpenableObjectsSourceCache.AddOrUpdate(DatabasesSourceCache.Items);


            AllOpenableObjectsSourceCache.Connect()
            .AutoRefresh(d => SearchTerm)
            .Filter(o => string.IsNullOrEmpty(SearchTerm) || o.Identifier.ToLower().Contains(SearchTerm.ToLower()))
            .ObserveOnDispatcher()
            .Bind(out var searchableOpenableObjects)
            .Subscribe();
            SearchableOpenableObjects = searchableOpenableObjects;
            #endregion
        }