/* TimePoint.cs * part of zaaReloaded2 * * Copyright 2015-2017 Daniel Kraus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Text; using System.Text.RegularExpressions; using zaaReloaded2.Thesaurus; namespace zaaReloaded2.LabModel { /// /// Holds laboratory items for a given time point. /// public class TimePoint { #region Properties /// /// Gets the date and time information for this TimePoint. /// If IsValidTimePoint is false, the value of TimeStamp /// is undefined. /// public DateTime TimeStamp { get; set; } /// /// Returns a sorted dictionary of all s found in /// the . If a laboratory parameter occurs more /// than once, only the last occurrence is saved. /// public IItemDictionary Items { get; private set; } #endregion #region Constructor public TimePoint() { Items = new ItemDictionary(); } #endregion #region Methods /// /// Adds an item to the TimePoint. /// /// LabItem to add. public void AddItem(LabItem item) { if (String.IsNullOrEmpty(item.QualifiedName)) { throw new ArgumentException("Cannot add item that has no qualified name."); } Items.Add(item.QualifiedName, item); } /// /// Adds the items from another time point to this /// time point. There is no check for plausibility, /// i.e. the other time point may have a different /// time stamp. /// /// Other TimePoint to /// merge into the current one. public void MergeItems(TimePoint otherTimePoint) { if (otherTimePoint == null) throw new ArgumentNullException("otherTimePoint"); Items.Merge(otherTimePoint.Items); } /// /// Returns true if contains a given /// item. /// /// Item string to look for. /// True if contains /// public bool ContainsItem(string item) { return Items.ContainsKey(item); } #endregion } }