Exemple #1
0
 public static TValue Unpack <TValue>(ref TValue value, int from, int to)
 {
     if (typeof(TValue) == typeof(sbyte) || typeof(TValue) == typeof(byte))
     {
         return(UnsafeEx.As <byte, TValue>(BitHelper.Unpack(Unsafe.As <TValue, byte>(ref value), from, to)));
     }
     else if (typeof(TValue) == typeof(short) || typeof(TValue) == typeof(ushort))
     {
         return(UnsafeEx.As <ushort, TValue>(BitHelper.Unpack(Unsafe.As <TValue, ushort>(ref value), from, to)));
     }
     else if (typeof(TValue) == typeof(int) || typeof(TValue) == typeof(uint))
     {
         return(UnsafeEx.As <uint, TValue>(BitHelper.Unpack(Unsafe.As <TValue, uint>(ref value), from, to)));
     }
     else if (typeof(TValue) == typeof(long) || typeof(TValue) == typeof(ulong))
     {
         return(UnsafeEx.As <ulong, TValue>(BitHelper.Unpack(Unsafe.As <TValue, ulong>(ref value), from, to)));
     }
     else
     {
         throw new ArgumentException(nameof(TValue));
     }
 }
Exemple #2
0
 public uint Unpack(uint value)
 => BitHelper.Unpack(value, From, To);
Exemple #3
0
 public ushort Unpack(ushort value)
 => BitHelper.Unpack(value, From, To);
Exemple #4
0
 public byte Unpack(byte value)
 => BitHelper.Unpack(value, From, To);