public bool IsInGroup(IFieldDefinitionRecord group) => (group.Offset <= Offset) && ((group.Offset + group.Length) >= (Offset + Length));
private TpsObject ParseField(TpsTypeCode type, int length, IFieldDefinitionRecord fieldDefinitionRecord, RandomAccess rx) { if (fieldDefinitionRecord == null) { throw new ArgumentNullException(nameof(fieldDefinitionRecord)); } if (rx == null) { throw new ArgumentNullException(nameof(rx)); } switch (type) { case TpsTypeCode.Byte: AssertEqual(1, length); return(new TpsByte(rx)); case TpsTypeCode.Short: AssertEqual(2, length); return(new TpsShort(rx)); case TpsTypeCode.UShort: AssertEqual(2, length); return(new TpsUnsignedShort(rx)); case TpsTypeCode.Date: return(new TpsDate(rx)); case TpsTypeCode.Time: return(new TpsTime(rx)); case TpsTypeCode.Long: AssertEqual(4, length); return(new TpsLong(rx)); case TpsTypeCode.ULong: AssertEqual(4, length); return(new TpsUnsignedLong(rx)); case TpsTypeCode.SReal: AssertEqual(4, length); return(new TpsFloat(rx)); case TpsTypeCode.Real: AssertEqual(8, length); return(new TpsDouble(rx)); case TpsTypeCode.Decimal: return(new TpsDecimal(rx, length, fieldDefinitionRecord.BcdDigitsAfterDecimalPoint)); case TpsTypeCode.String: return(new TpsString(rx, length, Encoding)); case TpsTypeCode.CString: return(new TpsCString(rx, Encoding)); case TpsTypeCode.PString: return(new TpsPString(rx, Encoding)); case TpsTypeCode.Group: return(new TpsGroup(rx, length)); default: throw new ArgumentException($"Unsupported type {type} ({length})", nameof(type)); } }