zaaReloaded2/zaaReloaded2/LabModel/TimePoint.cs
Daniel Kraus b421279208 Refactor: Rename lookup dictionaries to thesaurus.
This prevents confusion with the .NET term 'dictionary'.
2015-07-14 23:50:39 +02:00

107 lines
3.2 KiB
C#
Executable File

/* TimePoint.cs
* part of zaaReloaded2
*
* Copyright 2015 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
{
/// <summary>
/// Holds laboratory items for a given time point.
/// </summary>
public class TimePoint
{
#region Properties
/// <summary>
/// Gets the date and time information for this TimePoint.
/// If IsValidTimePoint is false, the value of TimeStamp
/// is undefined.
/// </summary>
public DateTime TimeStamp { get; set; }
/// <summary>
/// Returns a sorted dictionary of all <see cref="LabItem"/>s found in
/// the <see cref="LaurisText"/>. If a laboratory parameter occurs more
/// than once, only the last occurrence is saved.
/// </summary>
public IItemDictionary Items { get; private set; }
#endregion
#region Constructor
public TimePoint()
{
Items = new ItemDictionary();
}
#endregion
#region Methods
/// <summary>
/// Adds an item to the TimePoint.
/// </summary>
/// <param name="item">LabItem to add.</param>
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);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="otherTimePoint">Other TimePoint to
/// merge into the current one.</param>
public void MergeItems(TimePoint otherTimePoint)
{
if (otherTimePoint == null)
throw new ArgumentNullException("otherTimePoint");
Items.Merge(otherTimePoint.Items);
}
/// <summary>
/// Returns true if <see cref="Items"/> contains a given
/// item.
/// </summary>
/// <param name="item">Item string to look for.</param>
/// <returns>True if <see cref="Items"/> contains <paramref name="item."/>
/// </returns>
public bool ContainsItem(string item)
{
return Items.ContainsKey(item);
}
#endregion
}
}