Convert VariableAddress to record

This commit is contained in:
Peter Butzhammer
2024-02-09 12:46:45 +01:00
parent 996706df2f
commit 56b300b3ab
10 changed files with 62 additions and 72 deletions

View File

@@ -7,17 +7,17 @@ internal static class VariableAddressExtensions
private static readonly Dictionary<Type, Func<VariableAddress, bool>> supportedTypeMap = new()
{
{typeof(bool), a => a.Type == DbType.Bit},
{typeof(string), a => a.Type is DbType.String or DbType.WString or DbType.Byte },
{typeof(byte), a => a.Type==DbType.Byte && a.Length == 1},
{typeof(short), a => a.Type==DbType.Int},
{typeof(ushort), a => a.Type==DbType.UInt},
{typeof(int), a => a.Type==DbType.DInt},
{typeof(uint), a => a.Type==DbType.UDInt},
{typeof(long), a => a.Type==DbType.LInt},
{typeof(ulong), a => a.Type==DbType.ULInt},
{typeof(float), a => a.Type==DbType.Single},
{typeof(double), a => a.Type==DbType.Double},
{typeof(byte[]), a => a.Type==DbType.Byte},
{typeof(string), a => a.Type is DbType.String or DbType.WString or DbType.Byte},
{typeof(byte), a => a.Type == DbType.Byte && a.Length == 1},
{typeof(short), a => a.Type == DbType.Int},
{typeof(ushort), a => a.Type == DbType.UInt},
{typeof(int), a => a.Type == DbType.DInt},
{typeof(uint), a => a.Type == DbType.UDInt},
{typeof(long), a => a.Type == DbType.LInt},
{typeof(ulong), a => a.Type == DbType.ULInt},
{typeof(float), a => a.Type == DbType.Single},
{typeof(double), a => a.Type == DbType.Double},
{typeof(byte[]), a => a.Type == DbType.Byte},
};
public static bool MatchesType(this VariableAddress address, Type type) =>