private ReadingDto ReadLastReading() { ReadingDto readingDto = null; if (this.reader.IsEmptyElement != true) { this.reader.Read(); readingDto = new ReadingDto(); // Value this.reader.ReadStartElement("Value"); readingDto.Value = this.reader.ReadContentAsDouble(); this.reader.ReadEndElement(); // Timestamp this.reader.ReadStartElement("Timestamp"); readingDto.Timestamp = this.reader.ReadContentAsDateTime(); this.reader.ReadEndElement(); this.reader.ReadEndElement(); } else { this.reader.Read(); } return(readingDto); }
internal ReadingDto CreateDto() { ReadingDto Dto = new ReadingDto(); Dto.Dao = this.dao; Dto.Value = this.value; Dto.Timestamp = this.timestamp; return(Dto); }
private void WriteLastReading(ReadingDto readingDto) { // Last reading this.writer.WriteStartElement("LastReading"); if (readingDto != null) { // Value this.writer.WriteStartElement("Value"); this.writer.WriteValue(readingDto.Value); this.writer.WriteEndElement(); // Timestamp this.writer.WriteStartElement("Timestamp"); this.writer.WriteValue(readingDto.Timestamp); this.writer.WriteEndElement(); } this.writer.WriteEndElement(); }
private ReadingCollectionDto ReadAccumulatedReadings() { ReadingCollectionDto dto = new ReadingCollectionDto(); if (this.reader.IsEmptyElement != true) { this.reader.Read(); do { this.reader.Read(); ReadingDto reading = new ReadingDto(); // Value this.reader.ReadStartElement("Value"); reading.Value = this.reader.ReadContentAsDouble(); this.reader.ReadEndElement(); // Timestamp this.reader.ReadStartElement("Timestamp"); reading.Timestamp = this.reader.ReadContentAsDateTime(); this.reader.ReadEndElement(); dto.Add(reading); } while (this.reader.ReadToNextSibling("Reading")); this.reader.ReadEndElement(); } else { this.reader.Read(); } return(dto); }
internal void FixupFromDto(ReadingDto dto) { this.dao = dto.Dao; this.value = dto.Value; this.timestamp = dto.Timestamp; }
/// <summary> /// Add a reading to the queue /// </summary> /// <param name="dto">New reading to add</param> public void Add(ReadingDto newReadingDto) { this.readings.Add(newReadingDto); }