diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
index 931ba1d02..9c5953749 100644
--- a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
+++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
@@ -213,9 +213,25 @@ namespace Artemis.Core
Expression? expression = Expression.Convert(parameter, Target.GetType());
Expression? nullCondition = null;
+ MethodInfo equals = typeof(object).GetMethod("Equals", BindingFlags.Static | BindingFlags.Public)!;
foreach (DataModelPathSegment segment in _segments)
{
- BinaryExpression notNull = Expression.NotEqual(expression, Expression.Default(expression.Type));
+ BinaryExpression notNull;
+ try
+ {
+ notNull = Expression.NotEqual(expression, Expression.Default(expression.Type));
+ }
+ catch (InvalidOperationException)
+ {
+ notNull = Expression.NotEqual(
+ Expression.Call(
+ null,
+ equals,
+ Expression.Convert(expression, typeof(object)),
+ Expression.Convert(Expression.Default(expression.Type), typeof(object))),
+ Expression.Constant(true));
+ }
+
nullCondition = nullCondition != null ? Expression.AndAlso(nullCondition, notNull) : notNull;
expression = segment.Initialize(parameter, expression, nullCondition);
if (expression == null)
diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
index fca0a0970..213cf4533 100644
--- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
+++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml
@@ -19,6 +19,10 @@
+
+
+
+
@@ -48,6 +52,17 @@
IsEnabled="{Binding IsModuleFilterEnabled}"
SelectedItem="{Binding SelectedModule}"
ItemsSource="{Binding Modules}" />
+
+
+ Slow updates
+
+
+
diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
index 442b0996d..e2b83d7d0 100644
--- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
+++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugViewModel.cs
@@ -20,12 +20,13 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
private DataModelPropertiesViewModel _mainDataModel;
private string _propertySearch;
private Module _selectedModule;
+ private bool _slowUpdates;
public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
{
_dataModelUIService = dataModelUIService;
_pluginManagementService = pluginManagementService;
- _updateTimer = new Timer(500);
+ _updateTimer = new Timer(25);
DisplayName = "Data model";
Modules = new BindableCollection();
@@ -43,6 +44,16 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
set => SetAndNotify(ref _propertySearch, value);
}
+ public bool SlowUpdates
+ {
+ get => _slowUpdates;
+ set
+ {
+ SetAndNotify(ref _slowUpdates, value);
+ _updateTimer.Interval = _slowUpdates ? 500 : 25;
+ }
+ }
+
public BindableCollection Modules { get; }
public Module SelectedModule
diff --git a/src/Artemis.UI/Services/UpdateService.cs b/src/Artemis.UI/Services/UpdateService.cs
index 96fdcf661..ac00d5426 100644
--- a/src/Artemis.UI/Services/UpdateService.cs
+++ b/src/Artemis.UI/Services/UpdateService.cs
@@ -16,7 +16,6 @@ using Artemis.UI.Shared.Services;
using Flurl;
using Flurl.Http;
using MaterialDesignThemes.Wpf;
-using Newtonsoft.Json.Linq;
using Serilog;
using File = System.IO.File;
@@ -27,8 +26,8 @@ namespace Artemis.UI.Services
private const string ApiUrl = "https://dev.azure.com/artemis-rgb/Artemis/_apis/";
private readonly PluginSetting _autoInstallUpdates;
private readonly PluginSetting _checkForUpdates;
- private readonly ILogger _logger;
private readonly IDialogService _dialogService;
+ private readonly ILogger _logger;
private readonly IMessageService _messageService;
private readonly IWindowService _windowService;
@@ -46,6 +45,32 @@ namespace Artemis.UI.Services
_checkForUpdates.SettingChanged += CheckForUpdatesOnSettingChanged;
}
+ private async Task OfferUpdate(DevOpsBuild buildInfo)
+ {
+ await _dialogService.ShowDialog(new Dictionary {{"buildInfo", buildInfo}});
+ }
+
+ private async Task UpdateInstaller()
+ {
+ string downloadUrl = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
+ string installerDirectory = Path.Combine(Constants.ApplicationFolder, "Installer");
+ string installerPath = Path.Combine(installerDirectory, "Artemis.Installer.exe");
+
+ _logger.Information("UpdateInstaller: Downloading installer from {downloadUrl}", downloadUrl);
+ using HttpClient client = new();
+ HttpResponseMessage httpResponseMessage = await client.GetAsync(downloadUrl);
+ if (!httpResponseMessage.IsSuccessStatusCode)
+ throw new ArtemisUIException($"Failed to download installer, status code {httpResponseMessage.StatusCode}");
+
+ _logger.Information("UpdateInstaller: Writing installer file to {installerPath}", installerPath);
+ if (File.Exists(installerPath))
+ File.Delete(installerPath);
+
+ Core.Utilities.CreateAccessibleDirectory(installerDirectory);
+ await using FileStream fs = new(installerPath, FileMode.Create, FileAccess.Write, FileShare.None);
+ await httpResponseMessage.Content.CopyToAsync(fs);
+ }
+
public async Task AutoUpdate()
{
if (!_checkForUpdates.Value)
@@ -68,7 +93,9 @@ namespace Artemis.UI.Services
return false;
if (_windowService.IsMainWindowOpen)
+ {
await OfferUpdate(buildInfo);
+ }
else if (_autoInstallUpdates.Value)
{
// Lets go
@@ -92,11 +119,6 @@ namespace Artemis.UI.Services
return true;
}
- private async Task OfferUpdate(DevOpsBuild buildInfo)
- {
- await _dialogService.ShowDialog(new Dictionary {{"buildInfo", buildInfo}});
- }
-
public async Task IsUpdateAvailable()
{
DevOpsBuild buildInfo = await GetBuildInfo(1);
@@ -114,7 +136,9 @@ namespace Artemis.UI.Services
// Always update installer if it is missing ^^
if (!File.Exists(installerPath))
+ {
await UpdateInstaller();
+ }
// Compare the creation date of the installer with the build date and update if needed
else
{
@@ -182,27 +206,6 @@ namespace Artemis.UI.Services
.GetJsonAsync();
}
- private async Task UpdateInstaller()
- {
- string downloadUrl = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
- string installerDirectory = Path.Combine(Constants.ApplicationFolder, "Installer");
- string installerPath = Path.Combine(installerDirectory, "Artemis.Installer.exe");
-
- _logger.Information("UpdateInstaller: Downloading installer from {downloadUrl}", downloadUrl);
- using HttpClient client = new();
- HttpResponseMessage httpResponseMessage = await client.GetAsync(downloadUrl);
- if (!httpResponseMessage.IsSuccessStatusCode)
- throw new ArtemisUIException($"Failed to download installer, status code {httpResponseMessage.StatusCode}");
-
- _logger.Information("UpdateInstaller: Writing installer file to {installerPath}", installerPath);
- if (File.Exists(installerPath))
- File.Delete(installerPath);
- else if (!Directory.Exists(installerDirectory))
- Directory.CreateDirectory(installerDirectory);
- await using FileStream fs = new(installerPath, FileMode.Create, FileAccess.Write, FileShare.None);
- await httpResponseMessage.Content.CopyToAsync(fs);
- }
-
#region Event handlers
private void CheckForUpdatesOnSettingChanged(object sender, EventArgs e)