Example #1
0
            internal ReadingCollectionDto CreateDto()
            {
                ReadingCollectionDto dto = new ReadingCollectionDto();

                dto.MaxReadings = this.maxSize;
                foreach (Reading reading in this.readings)
                {
                    dto.Add(reading.CreateDto());
                }
                return(dto);
            }
Example #2
0
            /// <summary>
            /// Fix up the reading collection from the given DTOs
            /// </summary>
            /// <param name="readingCollectionDto">Reading DTO collection</param>
            internal void FixupFromDto(ReadingCollectionDto readingCollectionDto)
            {
                this.dao = readingCollectionDto.Dao;

                foreach (ReadingDto readingDto in readingCollectionDto)
                {
                    Reading newReading = new Reading();
                    newReading.FixupFromDto(readingDto);
                    this.readings.Add(newReading);
                }
            }
Example #3
0
        private void WriteAccumulatedReadings(ReadingCollectionDto dto)
        {
            this.writer.WriteStartElement("AccumulatedReadings");
            ReadingDto[] readings = dto.Readings;
            foreach (ReadingDto reading in readings)
            {
                this.writer.WriteStartElement("Reading");

                // Value
                this.writer.WriteStartElement("Value");
                this.writer.WriteValue(reading.Value);
                this.writer.WriteEndElement();
                // Timestamp
                this.writer.WriteStartElement("Timestamp");
                this.writer.WriteValue(reading.Timestamp);
                this.writer.WriteEndElement();

                this.writer.WriteEndElement();
            }
            this.writer.WriteEndElement();
        }
Example #4
0
        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);
        }