/// <summary> /// Updates the values contained by the vector element identified by the given tag /// or adds a new vector element if one does not already exist. /// </summary> /// <param name="tag">The tag which identifies the vector element to be updated.</param> /// <param name="type">The physical type of the values contained in the vector element.</param> /// <param name="bytes">The values to be entered into the vector element.</param> /// <returns>The vector element which was updated, or a new vector element if one did not already exist.</returns> public VectorElement AddOrUpdateVector(Guid tag, PhysicalType type, byte[] bytes) { VectorElement vectorElement = GetOrAddVector(tag); vectorElement.TypeOfValue = type; vectorElement.Size = bytes.Length / type.GetByteSize(); vectorElement.SetValues(bytes, 0); return(vectorElement); }
private int GetByteSize(VectorElement vector) { if ((object)vector == null) { return(0); } return(4 + (vector.Size * vector.TypeOfValue.GetByteSize())); }
// Reads a vector element from the PQDIF file. private VectorElement ReadVector(BinaryReader recordBodyReader, PhysicalType typeOfValue) { VectorElement element = new VectorElement() { Size = recordBodyReader.ReadInt32(), TypeOfValue = typeOfValue }; byte[] values = recordBodyReader.ReadBytes(element.Size * typeOfValue.GetByteSize()); element.SetValues(values, 0); return(element); }
/// <summary> /// Gets the vector element identified by the given tag /// or adds a new vector element if one does not already exist. /// </summary> /// <param name="tag">The tag which identifies the vector element to be retrieved.</param> /// <returns>The vector element identified by the tag, or a new vector element if one did not already exist.</returns> public VectorElement GetOrAddVector(Guid tag) { VectorElement vectorElement = GetVectorByTag(tag); if ((object)vectorElement == null) { vectorElement = new VectorElement() { TagOfElement = tag }; AddElement(vectorElement); } return(vectorElement); }
private int GetByteSize(VectorElement vector) { if ((object)vector == null) return 0; return 4 + (vector.Size * vector.TypeOfValue.GetByteSize()); }
private void WriteVector(BinaryWriter writer, VectorElement vector) { writer.Write(vector.Size); writer.Write(vector.GetValues()); }
// Reads a vector element from the PQDIF file. private VectorElement ReadVector(BinaryReader recordBodyReader, PhysicalType typeOfValue) { VectorElement element = new VectorElement() { Size = recordBodyReader.ReadInt32(), TypeOfValue = typeOfValue }; byte[] values = recordBodyReader.ReadBytes(element.Size * typeOfValue.GetByteSize()); element.SetValues(values, 0); return element; }