From f485a87b30c9874f224cfd6ce4cfd3d59e227a80 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 20 Nov 2024 10:11:35 -0500 Subject: [PATCH] add minstudioversion for plugins --- src/OneWare.Core/Data/Global.cs | 4 +++- .../PackageManager/PackageVersion.cs | 2 ++ .../ViewModels/PackageViewModel.cs | 12 ++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/OneWare.Core/Data/Global.cs b/src/OneWare.Core/Data/Global.cs index b2947905..d798e3a9 100644 --- a/src/OneWare.Core/Data/Global.cs +++ b/src/OneWare.Core/Data/Global.cs @@ -6,5 +6,7 @@ namespace OneWare.Core.Data; public static class Global { - public static string VersionCode => Assembly.GetEntryAssembly()!.GetName().Version?.ToString() ?? ""; + public static Version Version => Assembly.GetEntryAssembly()!.GetName().Version!; + + public static string VersionCode => Version.ToString() ?? ""; } \ No newline at end of file diff --git a/src/OneWare.Essentials/PackageManager/PackageVersion.cs b/src/OneWare.Essentials/PackageManager/PackageVersion.cs index c115c757..91e8c1cd 100644 --- a/src/OneWare.Essentials/PackageManager/PackageVersion.cs +++ b/src/OneWare.Essentials/PackageManager/PackageVersion.cs @@ -3,6 +3,8 @@ public class PackageVersion { public string? Version { get; init; } + + public string? MinStudioVersion { get; init; } public PackageTarget[]? Targets { get; init; } diff --git a/src/OneWare.PackageManager/ViewModels/PackageViewModel.cs b/src/OneWare.PackageManager/ViewModels/PackageViewModel.cs index 57e1efbb..5647a8ab 100644 --- a/src/OneWare.PackageManager/ViewModels/PackageViewModel.cs +++ b/src/OneWare.PackageManager/ViewModels/PackageViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Reflection; using Avalonia; using Avalonia.Controls; using Avalonia.Media; @@ -114,16 +115,19 @@ public AsyncRelayCommand? MainButtonCommand public AsyncRelayCommand InstallCommand { get; } public AsyncRelayCommand UpdateCommand { get; } - + private void InitPackage() { Links.Clear(); if (PackageModel.Package.Links != null) Links.AddRange(PackageModel.Package.Links.Select(x => new LinkModel(x.Name ?? "Link", x.Url ?? ""))); - + PackageVersionModels.Clear(); - if(PackageModel.Package.Versions != null) - PackageVersionModels.AddRange(PackageModel.Package.Versions.Select(x => new PackageVersionModel(x))); + if (PackageModel.Package.Versions != null) + PackageVersionModels.AddRange(PackageModel.Package.Versions + .Where(x => x.MinStudioVersion == null || Version.TryParse(x.MinStudioVersion, out var minVersion) + && Assembly.GetEntryAssembly()!.GetName().Version > minVersion) + .Select(x => new PackageVersionModel(x))); SelectedVersionModel = PackageVersionModels.LastOrDefault(); _resolveTabsStarted = false; _resolveImageStarted = false;