/// <summary> /// Initializes a new instance of the <see cref="IntegerArray"/> struct. /// </summary> /// <param name="source">The array range to wrap.</param> /// <param name="byteOffset">The zero-based index of the first <see cref="Byte"/> in <paramref name="source"/>.</param> /// <param name="itemsCount">The number of <see cref="UInt32"/> items in <paramref name="source"/>.</param> /// <param name="encoding">Byte encoding.</param> public IntegerArray(BYTES source, int byteOffset, int itemsCount, ENCODING encoding) { _Data = source.Slice(byteOffset); _ByteStride = encoding.ByteLength(); this._Setter = null; this._Getter = null; if (itemsCount < this.Count) { _Data = _Data.Slice(0, itemsCount * _ByteStride); } switch (encoding) { case ENCODING.UNSIGNED_BYTE: { this._Setter = this._SetValueU8; this._Getter = this._GetValueU8; break; } case ENCODING.UNSIGNED_SHORT: { this._Setter = this._SetValueU16; this._Getter = this._GetValueU16; break; } case ENCODING.UNSIGNED_INT: { this._Setter = this._SetValue <UInt32>; this._Getter = this._GetValue <UInt32>; break; } default: throw new ArgumentException("Unsupported encoding.", nameof(encoding)); } }
/// <summary> /// Initializes a new instance of the <see cref="IntegerArray"/> struct. /// </summary> /// <param name="source">The array to wrap.</param> /// <param name="byteOffset">The zero-based index of the first <see cref="Byte"/> in <paramref name="source"/>.</param> /// <param name="itemsCount">The number of <see cref="UInt32"/> items in <paramref name="source"/>.</param> /// <param name="encoding">Byte encoding.</param> public IntegerArray(Byte[] source, int byteOffset, int itemsCount, ENCODING encoding) : this(new BYTES(source), byteOffset, itemsCount, encoding) { }
/// <summary> /// Initializes a new instance of the <see cref="IntegerArray"/> struct. /// </summary> /// <param name="source">The array range to wrap.</param> /// <param name="encoding">Byte encoding.</param> public IntegerArray(BYTES source, ENCODING encoding = ENCODING.UNSIGNED_INT) : this(source, 0, int.MaxValue, encoding) { }