using System.Runtime.CompilerServices; namespace NIFPGA { public sealed class FPGAArrayReadProperty : FPGABaseProperty where T : unmanaged { private T[] tempvalue = new T[0]; private object lockObject = new object(); internal FPGAArrayReadProperty(FPGASession session, uint indicator, uint count) : base(session, indicator, true) { Count = count; tempvalue = new T[Count]; } private T[] GetValues() { lock (lockObject) { if (Count == 0) return tempvalue; switch (tempvalue[0]) { case (bool): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (byte): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (sbyte): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case short: _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (ushort): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (int): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (uint): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (long): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (ulong): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (float): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; case (double): _Session.CheckResult(_Session.GetDelegate()(_Session.Session, Indicator, ref Unsafe.As(ref tempvalue[0]), Count)); break; } return tempvalue; } } public uint Count { get; } public T[] Values => GetValues(); } }