using System; using Deltares.Standard.IO; using Deltares.Standard.Units; namespace Deltares.DeltaModel { public class AquoFieldDefinition : FieldDefinition { /// /// The unit used in the aquo file /// private readonly Enum importedUnit; /// /// The unit type of the /// private UnitType? importedUnitType; /// /// A field definition for conversion between a CSV adhering to the aquo standard and a property on a data model. /// The conversion factor is used for conversion between columns which are not using a SI-unit for their values. /// /// Name of the field in the imported file. /// Name of the property of the data model. /// The type of the unit of the field in the imported file. /// The unit of the field in the imported file. public AquoFieldDefinition(String columnName, String propertyName, UnitType? importedUnitType = null, Enum importedUnit = null) : base(columnName, propertyName) { this.importedUnit = importedUnit; this.importedUnitType = importedUnitType; } /// /// Returns a converted value of the value that is passed. /// /// A value that might have to be converted. /// A possibly converted value. public object GetBaseValue(double value) { if (importedUnitType.HasValue && null != importedUnit) { return UnitsManager.GetBaseValue(importedUnitType.Value, importedUnit, value); } return value; } } }