/// <summary> /// Updates the value of the scalar element identified by the given tag /// or adds a new scalar element if one does not already exist. /// </summary> /// <param name="tag">The tag which identifies the scalar element to be updated.</param> /// <param name="type">The physical type of the value contained in the scalar element.</param> /// <param name="bytes">The value to be entered into the scalar element.</param> /// <returns>The scalar element which was updated, or a new scalar element if one did not already exist.</returns> public ScalarElement AddOrUpdateScalar(Guid tag, PhysicalType type, byte[] bytes) { ScalarElement scalarElement = GetOrAddScalar(tag); scalarElement.TypeOfValue = type; scalarElement.SetValue(bytes, 0); return(scalarElement); }
private int GetByteSize(ScalarElement scalar) { if ((object)scalar == null) { return(0); } return(scalar.TypeOfValue.GetByteSize()); }
// Reads a scalar element from the PQDIF file. private ScalarElement ReadScalar(BinaryReader recordBodyReader, PhysicalType typeOfValue) { ScalarElement element = new ScalarElement() { TypeOfValue = typeOfValue }; byte[] value = recordBodyReader.ReadBytes(typeOfValue.GetByteSize()); element.SetValue(value, 0); return(element); }
/// <summary> /// Gets the scalar element identified by the given tag /// or adds a new scalar element if one does not already exist. /// </summary> /// <param name="tag">The tag which identifies the scalar element to be retrieved.</param> /// <returns>The scalar element identified by the tag, or a new scalar element if one did not already exist.</returns> public ScalarElement GetOrAddScalar(Guid tag) { ScalarElement scalarElement = GetScalarByTag(tag); if ((object)scalarElement == null) { scalarElement = new ScalarElement() { TagOfElement = tag }; AddElement(scalarElement); } return(scalarElement); }
private int GetByteSize(ScalarElement scalar) { if ((object)scalar == null) return 0; return scalar.TypeOfValue.GetByteSize(); }
private void WriteScalar(BinaryWriter writer, ScalarElement scalar) { writer.Write(scalar.GetValue()); }
// Reads a scalar element from the PQDIF file. private ScalarElement ReadScalar(BinaryReader recordBodyReader, PhysicalType typeOfValue) { ScalarElement element = new ScalarElement() { TypeOfValue = typeOfValue }; byte[] value = recordBodyReader.ReadBytes(typeOfValue.GetByteSize()); element.SetValue(value, 0); return element; }