add PropertyObject & PropertyValue, move to Pilz, make everything .net 8 only
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
|
||||
<StartupObject />
|
||||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
<DocumentationFile>Pilz.Drawing.xml</DocumentationFile>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Pilz.Net.Data;
|
||||
using Pilz.Data;
|
||||
|
||||
namespace Pilz.Net.Api.Client;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Pilz.Net.Data;
|
||||
using Pilz.Data;
|
||||
|
||||
namespace Pilz.Net.Api.Client;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Pilz.Net.Data;
|
||||
using Pilz.Data;
|
||||
|
||||
namespace Pilz.Net.Api.Client;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pilz.Extensions\Pilz.Extensions.csproj" />
|
||||
<ProjectReference Include="..\Pilz\Pilz.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworks>net6.0-windows;net8.0-windows;netframework4.8</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
<DocumentationFile>Pilz.Threading.xml</DocumentationFile>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>annotations</Nullable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<DocumentationFile>Pilz.UI.xml</DocumentationFile>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0-windows;netframework4.8</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<Version>2.1.1</Version>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Pilz.Net.Data;
|
||||
namespace Pilz.Data;
|
||||
|
||||
public abstract class DataManager : IDataManager
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Pilz.Net.Data;
|
||||
namespace Pilz.Data;
|
||||
|
||||
public class DataManagerEventArgs(IDataManager manager) : EventArgs
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Pilz.Net.Data;
|
||||
namespace Pilz.Data;
|
||||
|
||||
public interface IDataManager
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Pilz.Net.Data;
|
||||
namespace Pilz.Data;
|
||||
|
||||
public interface IDataObject
|
||||
{
|
||||
47
Pilz/Data/PropertyObject.cs
Normal file
47
Pilz/Data/PropertyObject.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace Pilz.Data;
|
||||
|
||||
#pragma warning disable CA2231
|
||||
|
||||
[Serializable]
|
||||
public struct PropertyObject<T>(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<T> 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>(T value) => new(value);
|
||||
|
||||
public static explicit operator T?(PropertyObject<T> value) => value.Value;
|
||||
}
|
||||
54
Pilz/Data/PropertyValue.cs
Normal file
54
Pilz/Data/PropertyValue.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Pilz.Data;
|
||||
|
||||
#pragma warning disable CA2231
|
||||
|
||||
[Serializable]
|
||||
public struct PropertyValue<T>(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<T> 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>(T value) => new(value);
|
||||
|
||||
public static explicit operator T(PropertyValue<T> value) => value.Value;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>annotations</Nullable>
|
||||
|
||||
Reference in New Issue
Block a user