From ea8b0d601f9a5e33cba22bd88d3df3192390b47a Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Tue, 11 Aug 2020 10:37:17 -0500 Subject: [PATCH] Removed RxUI from Wabbajack.Common --- Wabbajack.Common.Test/WorkQueueTests.cs | 1 - Wabbajack.Common/Error States/ErrorResponse.cs | 1 - Wabbajack.Common/Utils.cs | 4 ++-- Wabbajack.Common/Wabbajack.Common.csproj | 2 +- Wabbajack.Common/WorkQueue.cs | 7 +++---- .../Interventions/AUserIntervention.cs | 5 +++-- .../Interventions/ConfirmationIntervention.cs | 2 +- .../Interventions/IUserIntervention.cs | 2 +- Wabbajack.Test/RestartingDownloadsTests.cs | 1 + Wabbajack/Views/Compilers/CompilerView.xaml | 4 ++-- Wabbajack/Views/Installers/InstallationView.xaml | 2 +- .../Views/Interventions/ConfirmationInterventionView.xaml | 4 ++-- .../Interventions/ConfirmationInterventionView.xaml.cs | 2 +- 13 files changed, 18 insertions(+), 19 deletions(-) rename {Wabbajack.Common/StatusFeed => Wabbajack.Lib}/Interventions/AUserIntervention.cs (84%) rename {Wabbajack.Common/StatusFeed => Wabbajack.Lib}/Interventions/ConfirmationIntervention.cs (97%) rename {Wabbajack.Common/StatusFeed => Wabbajack.Lib}/Interventions/IUserIntervention.cs (97%) diff --git a/Wabbajack.Common.Test/WorkQueueTests.cs b/Wabbajack.Common.Test/WorkQueueTests.cs index ee5be9ef..5cf5924f 100644 --- a/Wabbajack.Common.Test/WorkQueueTests.cs +++ b/Wabbajack.Common.Test/WorkQueueTests.cs @@ -6,7 +6,6 @@ using System.Reactive.Linq; using System.Reactive.Subjects; using System.Threading; using System.Threading.Tasks; -using Splat; using Wabbajack; using Wabbajack.Common; using Xunit; diff --git a/Wabbajack.Common/Error States/ErrorResponse.cs b/Wabbajack.Common/Error States/ErrorResponse.cs index e06f4ed7..2aedfe1b 100644 --- a/Wabbajack.Common/Error States/ErrorResponse.cs +++ b/Wabbajack.Common/Error States/ErrorResponse.cs @@ -1,5 +1,4 @@ using System; -using DynamicData.Kernel; namespace Wabbajack { diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 250e2df2..09e1a7ec 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Net.Http; +using System.Reactive.Concurrency; using System.Reactive.Linq; using System.Reactive.Subjects; using System.Reflection; @@ -23,7 +24,6 @@ using IniParser.Model.Configuration; using IniParser.Parser; using Microsoft.Win32; using Newtonsoft.Json; -using ReactiveUI; using RocksDbSharp; using Wabbajack.Common.StatusFeed; using Wabbajack.Common.StatusFeed.Errors; @@ -107,7 +107,7 @@ namespace Wabbajack.Common AppLocalEvents = Observable.Merge(Observable.FromEventPattern(h => watcher.Changed += h, h => watcher.Changed -= h).Select(e => (FileEventType.Changed, e.EventArgs)), Observable.FromEventPattern(h => watcher.Created += h, h => watcher.Created -= h).Select(e => (FileEventType.Created, e.EventArgs)), Observable.FromEventPattern(h => watcher.Deleted += h, h => watcher.Deleted -= h).Select(e => (FileEventType.Deleted, e.EventArgs))) - .ObserveOn(RxApp.TaskpoolScheduler); + .ObserveOn(Scheduler.Default); watcher.EnableRaisingEvents = true; InitPatches(); } diff --git a/Wabbajack.Common/Wabbajack.Common.csproj b/Wabbajack.Common/Wabbajack.Common.csproj index 393df5ca..99c9a70d 100644 --- a/Wabbajack.Common/Wabbajack.Common.csproj +++ b/Wabbajack.Common/Wabbajack.Common.csproj @@ -51,12 +51,12 @@ - + diff --git a/Wabbajack.Common/WorkQueue.cs b/Wabbajack.Common/WorkQueue.cs index f935b5e7..540bd989 100644 --- a/Wabbajack.Common/WorkQueue.cs +++ b/Wabbajack.Common/WorkQueue.cs @@ -8,7 +8,6 @@ using System.Reactive.Subjects; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; -using DynamicData; using Wabbajack.Common.StatusFeed; [assembly: InternalsVisibleTo("Wabbajack.Test")] @@ -26,6 +25,7 @@ namespace Wabbajack.Common public static bool WorkerThread => AsyncLocalCurrentQueue.Value != null; public bool IsWorkerThread => WorkerThread; internal static readonly AsyncLocal AsyncLocalCurrentQueue = new AsyncLocal(); + public static WorkQueue? AsyncLocalQueue => AsyncLocalCurrentQueue.Value; private readonly Subject _Status = new Subject(); public IObservable Status => _Status; @@ -69,15 +69,14 @@ namespace Wabbajack.Common public WorkQueue(IObservable? numThreads) { // Hook onto the number of active threads subject, and subscribe to it for changes - _activeNumThreadsObservable + _disposables.Add(_activeNumThreadsObservable // Select the latest driving observable .Select(x => x ?? Observable.Return(Environment.ProcessorCount)) .Switch() .DistinctUntilChanged() // Add new threads if it increases .SelectTask(AddNewThreadsIfNeeded) - .Subscribe() - .DisposeWith(_disposables); + .Subscribe()); // Set the incoming driving observable to be active SetActiveThreadsObservable(numThreads); } diff --git a/Wabbajack.Common/StatusFeed/Interventions/AUserIntervention.cs b/Wabbajack.Lib/Interventions/AUserIntervention.cs similarity index 84% rename from Wabbajack.Common/StatusFeed/Interventions/AUserIntervention.cs rename to Wabbajack.Lib/Interventions/AUserIntervention.cs index 879d4feb..16dfe691 100644 --- a/Wabbajack.Common/StatusFeed/Interventions/AUserIntervention.cs +++ b/Wabbajack.Lib/Interventions/AUserIntervention.cs @@ -5,8 +5,9 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Input; using ReactiveUI; +using Wabbajack.Common; -namespace Wabbajack.Common +namespace Wabbajack.Lib { public abstract class AUserIntervention : ReactiveObject, IUserIntervention { @@ -17,7 +18,7 @@ namespace Wabbajack.Common private bool _handled; public bool Handled { get => _handled; set => this.RaiseAndSetIfChanged(ref _handled, value); } - public int CpuID { get; } = WorkQueue.AsyncLocalCurrentQueue.Value?.CpuId ?? WorkQueue.UnassignedCpuId; + public int CpuID { get; } = WorkQueue.AsyncLocalQueue?.CpuId ?? WorkQueue.UnassignedCpuId; public abstract void Cancel(); public ICommand CancelCommand { get; } diff --git a/Wabbajack.Common/StatusFeed/Interventions/ConfirmationIntervention.cs b/Wabbajack.Lib/Interventions/ConfirmationIntervention.cs similarity index 97% rename from Wabbajack.Common/StatusFeed/Interventions/ConfirmationIntervention.cs rename to Wabbajack.Lib/Interventions/ConfirmationIntervention.cs index de097c6e..2a3a585b 100644 --- a/Wabbajack.Common/StatusFeed/Interventions/ConfirmationIntervention.cs +++ b/Wabbajack.Lib/Interventions/ConfirmationIntervention.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using System.Windows.Input; using ReactiveUI; -namespace Wabbajack.Common +namespace Wabbajack.Lib { public abstract class ConfirmationIntervention : AUserIntervention { diff --git a/Wabbajack.Common/StatusFeed/Interventions/IUserIntervention.cs b/Wabbajack.Lib/Interventions/IUserIntervention.cs similarity index 97% rename from Wabbajack.Common/StatusFeed/Interventions/IUserIntervention.cs rename to Wabbajack.Lib/Interventions/IUserIntervention.cs index 1f2ce864..183703f5 100644 --- a/Wabbajack.Common/StatusFeed/Interventions/IUserIntervention.cs +++ b/Wabbajack.Lib/Interventions/IUserIntervention.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using ReactiveUI; using Wabbajack.Common.StatusFeed; -namespace Wabbajack.Common +namespace Wabbajack.Lib { /// /// Defines a message that requires user interaction. The user must perform some action diff --git a/Wabbajack.Test/RestartingDownloadsTests.cs b/Wabbajack.Test/RestartingDownloadsTests.cs index 3bf8b88f..dc46f0f0 100644 --- a/Wabbajack.Test/RestartingDownloadsTests.cs +++ b/Wabbajack.Test/RestartingDownloadsTests.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Wabbajack.Common; using Wabbajack.Common.StatusFeed; +using Wabbajack.Lib; using Wabbajack.Lib.Downloaders; using Xunit; using Xunit.Abstractions; diff --git a/Wabbajack/Views/Compilers/CompilerView.xaml b/Wabbajack/Views/Compilers/CompilerView.xaml index 95ff7a67..4cdd8a1a 100644 --- a/Wabbajack/Views/Compilers/CompilerView.xaml +++ b/Wabbajack/Views/Compilers/CompilerView.xaml @@ -2,7 +2,7 @@ x:Class="Wabbajack.CompilerView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:common="clr-namespace:Wabbajack.Common;assembly=Wabbajack.Common" + xmlns:lib="clr-namespace:Wabbajack.Lib;assembly=Wabbajack.Lib" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:local="clr-namespace:Wabbajack" @@ -200,7 +200,7 @@ ViewModel="{Binding}" /> - + - + diff --git a/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml b/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml index 4914fd74..c7e40cd9 100644 --- a/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml +++ b/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml @@ -2,14 +2,14 @@ x:Class="Wabbajack.ConfirmationInterventionView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:common="clr-namespace:Wabbajack.Common;assembly=Wabbajack.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Wabbajack" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:lib="clr-namespace:Wabbajack.Lib;assembly=Wabbajack.Lib" xmlns:rxui="http://reactiveui.net" d:DesignHeight="450" d:DesignWidth="800" - x:TypeArguments="common:ConfirmationIntervention" + x:TypeArguments="lib:ConfirmationIntervention" mc:Ignorable="d"> diff --git a/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml.cs b/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml.cs index 05c6222f..91f9d783 100644 --- a/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml.cs +++ b/Wabbajack/Views/Interventions/ConfirmationInterventionView.xaml.cs @@ -14,7 +14,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ReactiveUI; -using Wabbajack.Common; +using Wabbajack.Lib; namespace Wabbajack {