public int Read(byte[] data, int startOffset) { int offset = startOffset; _header = new ArrayHeader(data, offset); offset += _header.Size; long numberOfScalarsLong = _header.NumberOfScalarValues; if (numberOfScalarsLong > int.MaxValue) { throw new InvalidOperationException( "Sorry, but POI can't store array of properties with size of " + numberOfScalarsLong + " in memory"); } int numberOfScalars = (int)numberOfScalarsLong; _values = new TypedPropertyValue[numberOfScalars]; int type = _header._type; if (type == Variant.VT_VARIANT) { for (int i = 0; i < numberOfScalars; i++) { TypedPropertyValue typedPropertyValue = new TypedPropertyValue(); offset += typedPropertyValue.Read(data, offset); } } else { for (int i = 0; i < numberOfScalars; i++) { TypedPropertyValue typedPropertyValue = new TypedPropertyValue( type, null); offset += typedPropertyValue.ReadValuePadded(data, offset); } } return(offset - startOffset); }
public int Read(byte[] data, int startOffset) { int offset = startOffset; long longLength = LittleEndian.GetUInt(data, offset); offset += LittleEndian.INT_SIZE; if (longLength > int.MaxValue) { throw new InvalidOperationException("Vector is too long -- " + longLength); } int length = (int)longLength; _values = new TypedPropertyValue[length]; if (_type == Variant.VT_VARIANT) { for (int i = 0; i < length; i++) { TypedPropertyValue value = new TypedPropertyValue(); offset += value.Read(data, offset); _values[i] = value; } } else { for (int i = 0; i < length; i++) { TypedPropertyValue value = new TypedPropertyValue(_type, null); // be aware: not padded here offset += value.ReadValue(data, offset); _values[i] = value; } } return(offset - startOffset); }