using System.Runtime.CompilerServices; namespace NIFPGA { public sealed class FPGAReadProperty : FPGABaseProperty where T : unmanaged { internal FPGAReadProperty(FPGASession session, uint indicator) : base(session, indicator, true) { } private T GetValue() { T value = default; switch (value) { case Boolean: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case Byte: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case SByte: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case Int16: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case UInt16: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case Int32: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case UInt32: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case Int64: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case UInt64: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case Single: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; case double: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref value))); break; } return value; } public T Value => GetValue(); } }