diff --git a/Pilz.Collections/Pilz.Collections.csproj b/Pilz.Collections/Pilz.Collections.csproj index 2fddb09..42f381b 100644 --- a/Pilz.Collections/Pilz.Collections.csproj +++ b/Pilz.Collections/Pilz.Collections.csproj @@ -3,7 +3,7 @@ - net8.0;netstandard2.0 + net8.0 latest enable enable diff --git a/Pilz.Cryptography/Pilz.Cryptography.csproj b/Pilz.Cryptography/Pilz.Cryptography.csproj index 2b17e9f..b7e1f6d 100644 --- a/Pilz.Cryptography/Pilz.Cryptography.csproj +++ b/Pilz.Cryptography/Pilz.Cryptography.csproj @@ -1,7 +1,7 @@  - net8.0;netstandard2.0 + net8.0 latest diff --git a/Pilz.Drawing/Pilz.Drawing.vbproj b/Pilz.Drawing/Pilz.Drawing.vbproj index 4bb7f1a..1b38d2f 100644 --- a/Pilz.Drawing/Pilz.Drawing.vbproj +++ b/Pilz.Drawing/Pilz.Drawing.vbproj @@ -1,7 +1,7 @@  Windows - net8.0-windows;netframework4.8 + net8.0-windows latest 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 Pilz.Drawing.xml diff --git a/Pilz.Extensions/Pilz.Extensions.csproj b/Pilz.Extensions/Pilz.Extensions.csproj index 3344213..577f57d 100644 --- a/Pilz.Extensions/Pilz.Extensions.csproj +++ b/Pilz.Extensions/Pilz.Extensions.csproj @@ -1,7 +1,7 @@  - net8.0;netstandard2.0 + net8.0 latest enable enable diff --git a/Pilz.Gaming.Minecraft/Pilz.Gaming.Minecraft.csproj b/Pilz.Gaming.Minecraft/Pilz.Gaming.Minecraft.csproj index 46331f9..56d629f 100644 --- a/Pilz.Gaming.Minecraft/Pilz.Gaming.Minecraft.csproj +++ b/Pilz.Gaming.Minecraft/Pilz.Gaming.Minecraft.csproj @@ -1,7 +1,7 @@ - net6.0;net8.0 + net8.0 latest enable enable diff --git a/Pilz.Net.CloudProviders.Nextcloud/Pilz.Net.CloudProviders.Nextcloud.csproj b/Pilz.Net.CloudProviders.Nextcloud/Pilz.Net.CloudProviders.Nextcloud.csproj index 854f7f9..736cf60 100644 --- a/Pilz.Net.CloudProviders.Nextcloud/Pilz.Net.CloudProviders.Nextcloud.csproj +++ b/Pilz.Net.CloudProviders.Nextcloud/Pilz.Net.CloudProviders.Nextcloud.csproj @@ -1,7 +1,7 @@  - net6.0;net8.0 + net8.0 latest enable enable diff --git a/Pilz.Net/Api/Client/BaseChildItemClient.cs b/Pilz.Net/Api/Client/BaseChildItemClient.cs index 0e8b2c7..bcb40a1 100644 --- a/Pilz.Net/Api/Client/BaseChildItemClient.cs +++ b/Pilz.Net/Api/Client/BaseChildItemClient.cs @@ -1,5 +1,5 @@ -using Pilz.Net.Api.Messages; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Net.Api.Messages; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Client/BaseClient.cs b/Pilz.Net/Api/Client/BaseClient.cs index 41a72f3..c0b1745 100644 --- a/Pilz.Net/Api/Client/BaseClient.cs +++ b/Pilz.Net/Api/Client/BaseClient.cs @@ -1,5 +1,5 @@ -using Pilz.Net.Api.Messages; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Net.Api.Messages; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Client/BaseItemClient.cs b/Pilz.Net/Api/Client/BaseItemClient.cs index eb97d97..5df51bb 100644 --- a/Pilz.Net/Api/Client/BaseItemClient.cs +++ b/Pilz.Net/Api/Client/BaseItemClient.cs @@ -1,5 +1,5 @@ -using Pilz.Net.Api.Messages; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Net.Api.Messages; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Client/IBaseChildItemClient.cs b/Pilz.Net/Api/Client/IBaseChildItemClient.cs index 058c364..57ec171 100644 --- a/Pilz.Net/Api/Client/IBaseChildItemClient.cs +++ b/Pilz.Net/Api/Client/IBaseChildItemClient.cs @@ -1,4 +1,4 @@ -using Pilz.Net.Data; +using Pilz.Data; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Client/IBaseClient.cs b/Pilz.Net/Api/Client/IBaseClient.cs index cdfd231..9f83ef9 100644 --- a/Pilz.Net/Api/Client/IBaseClient.cs +++ b/Pilz.Net/Api/Client/IBaseClient.cs @@ -1,4 +1,4 @@ -using Pilz.Net.Data; +using Pilz.Data; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Client/IBaseItemClient.cs b/Pilz.Net/Api/Client/IBaseItemClient.cs index 4d58b7b..a0a44f6 100644 --- a/Pilz.Net/Api/Client/IBaseItemClient.cs +++ b/Pilz.Net/Api/Client/IBaseItemClient.cs @@ -1,4 +1,4 @@ -using Pilz.Net.Data; +using Pilz.Data; namespace Pilz.Net.Api.Client; diff --git a/Pilz.Net/Api/Server/BaseChildItemHandler.cs b/Pilz.Net/Api/Server/BaseChildItemHandler.cs index 7109e86..6fdfad2 100644 --- a/Pilz.Net/Api/Server/BaseChildItemHandler.cs +++ b/Pilz.Net/Api/Server/BaseChildItemHandler.cs @@ -1,5 +1,5 @@ -using Pilz.Extensions.Reflection; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Extensions.Reflection; using Pilz.Net.Extensions; using System.Diagnostics; diff --git a/Pilz.Net/Api/Server/BaseHandler.cs b/Pilz.Net/Api/Server/BaseHandler.cs index 1882592..c10c206 100644 --- a/Pilz.Net/Api/Server/BaseHandler.cs +++ b/Pilz.Net/Api/Server/BaseHandler.cs @@ -1,5 +1,5 @@ -using Pilz.Extensions.Reflection; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Extensions.Reflection; using Pilz.Net.Extensions; using System.Diagnostics; diff --git a/Pilz.Net/Api/Server/BaseItemHandler.cs b/Pilz.Net/Api/Server/BaseItemHandler.cs index 083f894..3af9c2a 100644 --- a/Pilz.Net/Api/Server/BaseItemHandler.cs +++ b/Pilz.Net/Api/Server/BaseItemHandler.cs @@ -1,5 +1,5 @@ -using Pilz.Extensions.Reflection; -using Pilz.Net.Data; +using Pilz.Data; +using Pilz.Extensions.Reflection; using Pilz.Net.Extensions; using System.Diagnostics; diff --git a/Pilz.Net/Pilz.Net.csproj b/Pilz.Net/Pilz.Net.csproj index 95f73cf..ff8731d 100644 --- a/Pilz.Net/Pilz.Net.csproj +++ b/Pilz.Net/Pilz.Net.csproj @@ -18,6 +18,11 @@ + + + + + \ No newline at end of file diff --git a/Pilz.Threading/Pilz.Threading.vbproj b/Pilz.Threading/Pilz.Threading.vbproj index 0d03e2b..d540002 100644 --- a/Pilz.Threading/Pilz.Threading.vbproj +++ b/Pilz.Threading/Pilz.Threading.vbproj @@ -1,7 +1,7 @@  Windows - net6.0-windows;net8.0-windows;netframework4.8 + net8.0-windows latest 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 Pilz.Threading.xml diff --git a/Pilz.UI.Telerik/Pilz.UI.Telerik.csproj b/Pilz.UI.Telerik/Pilz.UI.Telerik.csproj index 5d156a3..789d9dc 100644 --- a/Pilz.UI.Telerik/Pilz.UI.Telerik.csproj +++ b/Pilz.UI.Telerik/Pilz.UI.Telerik.csproj @@ -1,7 +1,7 @@  - net8.0-windows;netframework4.8 + net8.0-windows latest enable annotations diff --git a/Pilz.UI/Pilz.UI.csproj b/Pilz.UI/Pilz.UI.csproj index 08707fc..d780857 100644 --- a/Pilz.UI/Pilz.UI.csproj +++ b/Pilz.UI/Pilz.UI.csproj @@ -1,7 +1,7 @@  Windows - net8.0-windows;netframework4.8 + net8.0-windows latest Pilz.UI.xml true diff --git a/Pilz.Win32/Pilz.Win32.csproj b/Pilz.Win32/Pilz.Win32.csproj index bfb8a0c..2bcdcd0 100644 --- a/Pilz.Win32/Pilz.Win32.csproj +++ b/Pilz.Win32/Pilz.Win32.csproj @@ -1,7 +1,7 @@  - net8.0-windows;netframework4.8 + net8.0-windows latest true 2.1.1 diff --git a/Pilz.Net/Data/DataManager.cs b/Pilz/Data/DataManager.cs similarity index 99% rename from Pilz.Net/Data/DataManager.cs rename to Pilz/Data/DataManager.cs index 053ab40..ba89d19 100644 --- a/Pilz.Net/Data/DataManager.cs +++ b/Pilz/Data/DataManager.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace Pilz.Net.Data; +namespace Pilz.Data; public abstract class DataManager : IDataManager { diff --git a/Pilz.Net/Data/DataManagerEventArgs.cs b/Pilz/Data/DataManagerEventArgs.cs similarity index 88% rename from Pilz.Net/Data/DataManagerEventArgs.cs rename to Pilz/Data/DataManagerEventArgs.cs index 85b0978..b6e5027 100644 --- a/Pilz.Net/Data/DataManagerEventArgs.cs +++ b/Pilz/Data/DataManagerEventArgs.cs @@ -1,4 +1,4 @@ -namespace Pilz.Net.Data; +namespace Pilz.Data; public class DataManagerEventArgs(IDataManager manager) : EventArgs { diff --git a/Pilz.Net/Data/IDataManager.cs b/Pilz/Data/IDataManager.cs similarity index 98% rename from Pilz.Net/Data/IDataManager.cs rename to Pilz/Data/IDataManager.cs index 5117a65..3741493 100644 --- a/Pilz.Net/Data/IDataManager.cs +++ b/Pilz/Data/IDataManager.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace Pilz.Net.Data; +namespace Pilz.Data; public interface IDataManager { diff --git a/Pilz.Net/Data/IDataObject.cs b/Pilz/Data/IDataObject.cs similarity index 68% rename from Pilz.Net/Data/IDataObject.cs rename to Pilz/Data/IDataObject.cs index 562e335..964fafe 100644 --- a/Pilz.Net/Data/IDataObject.cs +++ b/Pilz/Data/IDataObject.cs @@ -1,4 +1,4 @@ -namespace Pilz.Net.Data; +namespace Pilz.Data; public interface IDataObject { diff --git a/Pilz/Data/PropertyObject.cs b/Pilz/Data/PropertyObject.cs new file mode 100644 index 0000000..befad56 --- /dev/null +++ b/Pilz/Data/PropertyObject.cs @@ -0,0 +1,47 @@ +namespace Pilz.Data; + +#pragma warning disable CA2231 + +[Serializable] +public struct PropertyObject(T value) where T : class +{ + private readonly bool hasValue = true; // Do not rename (binary serialization) + internal T? value = value; // Do not rename (binary serialization) or make readonly (can be mutated in ToString, etc.) + + public static PropertyObject Empty => default; + + public readonly bool HasValue + { + get => hasValue; + } + + public readonly T? Value + { + get + { + if (!hasValue) + throw new InvalidOperationException("No value"); + return value; + } + } + + public readonly T? GetValueOrDefault() => value; + + public readonly T? GetValueOrDefault(T defaultValue) => + hasValue ? value : defaultValue; + + public override readonly bool Equals(object? other) + { + if (!hasValue || value is null) return other == null; + if (other == null) return false; + return value.Equals(other); + } + + public override readonly int GetHashCode() => hasValue && value is not null ? value.GetHashCode() : 0; + + public override readonly string? ToString() => hasValue && value is not null ? value.ToString() : string.Empty; + + public static implicit operator PropertyObject(T value) => new(value); + + public static explicit operator T?(PropertyObject value) => value.Value; +} \ No newline at end of file diff --git a/Pilz/Data/PropertyValue.cs b/Pilz/Data/PropertyValue.cs new file mode 100644 index 0000000..b9115cb --- /dev/null +++ b/Pilz/Data/PropertyValue.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; + +namespace Pilz.Data; + +#pragma warning disable CA2231 + +[Serializable] +public struct PropertyValue(T value) where T : struct +{ + [JsonProperty(PropertyName = "HasValue")] + private readonly bool hasValue = true; // Do not rename (binary serialization) + [JsonProperty(PropertyName = "Value")] + internal T value = value; // Do not rename (binary serialization) or make readonly (can be mutated in ToString, etc.) + + [JsonIgnore] + public static PropertyValue Empty => default; + + [JsonIgnore] + public readonly bool HasValue + { + get => hasValue; + } + + [JsonIgnore] + public readonly T Value + { + get + { + if (!hasValue) + throw new InvalidOperationException("No value"); + return value; + } + } + + public readonly T GetValueOrDefault() => value; + + public readonly T GetValueOrDefault(T defaultValue) => + hasValue ? value : defaultValue; + + public override readonly bool Equals(object? other) + { + if (!hasValue) return other == null; + if (other == null) return false; + return value.Equals(other); + } + + public override readonly int GetHashCode() => hasValue ? value.GetHashCode() : 0; + + public override readonly string? ToString() => hasValue ? value.ToString() : string.Empty; + + public static implicit operator PropertyValue(T value) => new(value); + + public static explicit operator T(PropertyValue value) => value.Value; +} \ No newline at end of file diff --git a/Pilz/Pilz.csproj b/Pilz/Pilz.csproj index c41f657..a262610 100644 --- a/Pilz/Pilz.csproj +++ b/Pilz/Pilz.csproj @@ -1,7 +1,7 @@  - net8.0;netstandard2.0 + net8.0 latest enable annotations