Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<!-- https://learn.microsoft.com/de-de/dotnet/maui/fundamentals/data-binding/compiled-bindings?view=net-maui-9.0 -->
<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>
<WarningsAsErrors>MVVMTK0045</WarningsAsErrors>

<IsTrimmable>true</IsTrimmable>
<!-- Ref: https://learn.microsoft.com/en-us/dotnet/maui/deployment/trimming?view=net-maui-10.0#suppress-analysis-warnings -->
<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion conditions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<!-- Here you can choose if you want to build as executable or as package -->
<!----><DefineConstants>$(DefineConstants);NEWTONSOFT</DefineConstants>
<!--<DefineConstants>$(DefineConstants);NEWTONSOFT</DefineConstants>-->
<!--<DefineConstants>$(DefineConstants);NET9</DefineConstants>-->
<!----><DefineConstants>$(DefineConstants);NET10</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static MauiAppBuilder ConfigureLicensing(this MauiAppBuilder builder, Uri
public static MauiAppBuilder ConfigureAppUpdater(this MauiAppBuilder builder, ILicenseManager licenseManager, IDispatcher? dispatcher = null)
{
dispatcher ??= builder.Services.BuildServiceProvider().GetService<IDispatcher>();
AppUpdateManager manager = new(dispatcher, licenseManager);
AppUpdateManager manager = dispatcher is null ? new(licenseManager) : new(dispatcher, licenseManager);
builder.Services.AddSingleton<IAppUpdateManager>(manager);
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected virtual void OnError()
{
Error?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnError(EventArgs e)
protected virtual void OnError(LicenseErrorEventArgs e)
{
Error?.Invoke(this, e);
}
Expand Down
18 changes: 8 additions & 10 deletions src/SharedMauiCoreLibrary.Licensing/LicenseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using AndreasReitberger.Shared.Core.Licensing.Interfaces;
using AndreasReitberger.Shared.Core.Licensing.WooCommerce;
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
using RestSharp;
using System.Net;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -496,13 +495,12 @@ async Task<WooActivationResponse[]> QueryWooCommerceAsync(string action, ILicens
parameters.Add("domain", license.Domain);
}
string jsonResult = await RestApiCallAsync(command, Method.Get, parameters, new(10000));

WooActivationResponse[] result = JsonConvert.DeserializeObject<WooActivationResponse[]>(jsonResult);
WooActivationResponse[] result = JsonSerializer.Deserialize(jsonResult, LicenseSourceGenerationContext.Default.WooActivationResponseArray);
return result;
}
catch (Exception exc)
{
OnError(new ErrorEventArgs(exc) { });
OnError(new LicenseErrorEventArgs(exc) { });
return null;
}
}
Expand All @@ -526,12 +524,12 @@ async Task<WooCodeVersionResponse[]> QueryLatestApplicationVersionFromWooCommerc
}
string jsonResult = await RestApiCallAsync(command, Method.Get, parameters, new(10000));

WooCodeVersionResponse[] result = JsonConvert.DeserializeObject<WooCodeVersionResponse[]>(jsonResult);
WooCodeVersionResponse[] result = JsonSerializer.Deserialize(jsonResult, LicenseSourceGenerationContext.Default.WooCodeVersionResponseArray);
return result;
}
catch (Exception exc)
{
OnError(new ErrorEventArgs(exc) { });
OnError(new LicenseErrorEventArgs(exc) { });
return null;
}
}
Expand All @@ -546,12 +544,12 @@ async Task<WooCodeVersionResponse[]> QueryLatestApplicationVersionFromWooCommerc
{ "product_unique_id", productCode }
};
string jsonResult = await RestApiCallAsync(command, Method.Get, parameters, new(10000));
WooCodeVersionResponse[] result = JsonConvert.DeserializeObject<WooCodeVersionResponse[]>(jsonResult);
WooCodeVersionResponse[] result = JsonSerializer.Deserialize(jsonResult, LicenseSourceGenerationContext.Default.WooCodeVersionResponseArray);
return result;
}
catch (Exception exc)
{
OnError(new ErrorEventArgs(exc) { });
OnError(new LicenseErrorEventArgs(exc) { });
return null;
}
}
Expand All @@ -573,12 +571,12 @@ async Task<EnvatoVerifyPurchaseCodeRespone> QueryEnvatoAsync(ILicenseInfo licens
};
string jsonResult = await RestApiCallAsync(command, Method.Get, parameters: parameters, headers: headers, new(10000));

EnvatoVerifyPurchaseCodeRespone result = JsonConvert.DeserializeObject<EnvatoVerifyPurchaseCodeRespone>(jsonResult);
EnvatoVerifyPurchaseCodeRespone result = JsonSerializer.Deserialize(jsonResult, LicenseSourceGenerationContext.Default.EnvatoVerifyPurchaseCodeRespone);
return result;
}
catch (Exception exc)
{
OnError(new ErrorEventArgs(exc) { });
OnError(new LicenseErrorEventArgs(exc) { });
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AndreasReitberger.Shared.Core.Licensing.Interfaces;
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.Envato
{
Expand All @@ -19,31 +18,31 @@ public partial class EnvatoActivationResponse : ObservableObject, IActivationRes
{
#region Properties
[ObservableProperty]
[JsonProperty("activated")]
[JsonPropertyName("activated")]
public partial bool Activated { get; set; } = false;

[ObservableProperty]
[JsonProperty("instance")]
[JsonPropertyName("instance")]
public partial int Instance { get; set; }

[ObservableProperty]
[JsonProperty("message")]
[JsonPropertyName("message")]
public partial string Message { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("timestamp")]
[JsonPropertyName("timestamp")]
public partial int Timestamp { get; set; }

[ObservableProperty]
[JsonProperty("sig")]
[JsonPropertyName("sig")]
public partial string Sig { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("code")]
[JsonPropertyName("code")]
public partial string ErrorCode { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("error")]
[JsonPropertyName("error")]
public partial string ErrorMessage { get; set; } = string.Empty;
#endregion
}
Expand Down
15 changes: 7 additions & 8 deletions src/SharedMauiCoreLibrary.Licensing/Models/Envato/EnvatoItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.Envato
{
Expand All @@ -17,31 +16,31 @@ public partial class EnvatoItem : ObservableObject
{
#region Properties
[ObservableProperty]
[JsonProperty("id")]
[JsonPropertyName("id")]
public partial string Id { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("name")]
[JsonPropertyName("name")]
public partial string ItemName { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("number_of_sales")]
[JsonPropertyName("number_of_sales")]
public partial string Sales { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("author_username")]
[JsonPropertyName("author_username")]
public partial string Author { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("author_url")]
[JsonPropertyName("author_url")]
public partial string AuthorUrl { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("url")]
[JsonPropertyName("url")]
public partial string Url { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("updatedAt")]
[JsonPropertyName("updatedAt")]
public partial string UpdatedAt { get; set; } = string.Empty;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.Envato
{
Expand All @@ -17,31 +16,31 @@ public partial class EnvatoVerifyPurchaseCodeRespone : ObservableObject
{
#region Properties
[ObservableProperty]
[JsonProperty("amount")]
[JsonPropertyName("amount")]
public partial string Amount { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("sold_At")]
[JsonPropertyName("sold_At")]
public partial string SoldAt { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("license")]
[JsonPropertyName("license")]
public partial string License { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("support_amount")]
[JsonPropertyName("support_amount")]
public partial string SupportAmount { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("supported_until")]
[JsonPropertyName("supported_until")]
public partial string SupportedUntil { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("item")]
[JsonPropertyName("item")]
public partial EnvatoItem? Item { get; set; }

[ObservableProperty]
[JsonProperty("code")]
[JsonPropertyName("code")]
public partial string PurchaseCode { get; set; } = string.Empty;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.Events
namespace AndreasReitberger.Shared.Core.Licensing.Events
{
public class LicenseChangedEventArgs : EventArgs
{
Expand All @@ -12,7 +10,7 @@ public class LicenseChangedEventArgs : EventArgs
#endregion

#region Overrides
public override string ToString() => JsonConvert.SerializeObject(this, Formatting.Indented);
public override string ToString() => JsonSerializer.Serialize(this!, LicenseSourceGenerationContext.Default.LicenseChangedEventArgs);
#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace AndreasReitberger.Shared.Core.Licensing.Events
{
public class LicenseErrorEventArgs : EventArgs
{
#region Properties
public string ErrorMessage { get; set; } = string.Empty;
public Exception? Exception { get; set; }
#endregion

#region Ctor
public LicenseErrorEventArgs() { }
public LicenseErrorEventArgs(Exception exc)
{
Exception = exc;
ErrorMessage = exc.Message;
}
#endregion

#region Overrides
public override string ToString() => JsonSerializer.Serialize(this!, LicenseSourceGenerationContext.Default.LicenseErrorEventArgs);
#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AndreasReitberger.Shared.Core.Licensing.Interfaces;
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.WooCommerce
{
Expand All @@ -15,15 +14,15 @@ public partial class WooActivationResponse : ObservableObject, IActivationRespon
#region Properties

[ObservableProperty]
[JsonProperty("status")]
[JsonPropertyName("status")]
public partial string Status { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("status_code")]
[JsonPropertyName("status_code")]
public partial string ErrorCode { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("message")]
[JsonPropertyName("message")]
public partial string ErrorMessage { get; set; } = string.Empty;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.WooCommerce
{
public partial class WooCodeVersionBanners : ObservableObject
{
#region Properties
[ObservableProperty]
[JsonProperty("low")]
[JsonPropertyName("low")]
public partial string LowQualityBanner { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("high")]
[JsonPropertyName("high")]
public partial string HighQualityBanner { get; set; } = string.Empty;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace AndreasReitberger.Shared.Core.Licensing.WooCommerce
{
Expand All @@ -21,43 +20,43 @@ public partial class WooCodeVersionMessage : ObservableObject
#region Properties

[ObservableProperty]
[JsonProperty("name")]
[JsonPropertyName("name")]
public partial string Name { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("version")]
[JsonPropertyName("version")]
public partial string Version { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("last_updated")]
[JsonPropertyName("last_updated")]
public partial string LastUpdated { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("upgrade_notice")]
[JsonPropertyName("upgrade_notice")]
public partial string UpgradeNotice { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("author")]
[JsonPropertyName("author")]
public partial string Author { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("tested")]
[JsonPropertyName("tested")]
public partial string Tested { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("requires")]
[JsonPropertyName("requires")]
public partial string Requires { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("homepage")]
[JsonPropertyName("homepage")]
public partial string Homepage { get; set; } = string.Empty;

[ObservableProperty]
[JsonProperty("sections")]
[JsonPropertyName("sections")]
public partial Dictionary<string, string> Sections { get; set; } = [];

[ObservableProperty]
[JsonProperty("banners")]
[JsonPropertyName("banners")]
public partial WooCodeVersionBanners? Banners { get; set; }

#endregion
Expand Down
Loading
Loading