// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using Deltares.Standard.Extensions; namespace Deltares.Dam.Data.Importers; internal static class LocationImportHelper { internal static PLLineCreationMethod ToPLLineCreationMethod(object value) { if (value == null) { throw new ArgumentNullException("value"); } return ToPLLineCreationMethod(value.ToString()); } internal static PLLineCreationMethod ToPLLineCreationMethod(string value) { if (string.IsNullOrEmpty(value) || value.Trim() == "") { throw new ArgumentException("value"); } var translationTable = new Dictionary { { "none", PLLineCreationMethod.None }, { "expertknowledgelinearindike", PLLineCreationMethod.ExpertKnowledgeLinearInDike }, { "expertknowledgerrd", PLLineCreationMethod.ExpertKnowledgeRRD }, { "gaugeswithfallbacktoexpertknowledgerrd", PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD } }; string key = value.ToLowerInvariant(); return key.ToEnumType(translationTable); } internal static IntrusionVerticalWaterPressureType ToIntrusionVerticalWaterPressure(object value) { if (value == null) { throw new ArgumentNullException("value"); } return ToIntrusionVerticalWaterPressure(value.ToString()); } internal static IntrusionVerticalWaterPressureType ToIntrusionVerticalWaterPressure(string value) { if (string.IsNullOrEmpty(value) || value.Trim() == "") { throw new ArgumentException("value"); } var translationTable = new Dictionary { { "fullhydrostatic", IntrusionVerticalWaterPressureType.FullHydroStatic }, { "hydrostatic", IntrusionVerticalWaterPressureType.HydroStatic }, { "linear", IntrusionVerticalWaterPressureType.Linear }, { "semitimedependent", IntrusionVerticalWaterPressureType.SemiTimeDependent }, { "standard", IntrusionVerticalWaterPressureType.Standard } }; string key = value.ToLowerInvariant(); return key.ToEnumType(translationTable); } internal static MStabZonesType ToMStabZonesTypeMethod(object value) { if (value == null) { throw new ArgumentNullException("value"); } return ToMStabZonesTypeMethod(value.ToString()); } /// /// Convert string to stability zonetype. /// /// The value. /// internal static MStabZonesType ToMStabZonesTypeMethod(string value) { if (string.IsNullOrEmpty(value) || value.Trim() == "") { throw new ArgumentException("value"); } var translationTable = new Dictionary { { "NoZones", MStabZonesType.NoZones }, { "ForbiddenZone", MStabZonesType.ForbiddenZone } }; string key = value.ToLowerInvariant(); return key.ToEnumType(translationTable); } /// /// Converts an object type (which IS a string) to a StabilityDesignMethod /// /// The value to convert /// /// if is null internal static StabilityDesignMethod ToStabilityDesignMethod(object value) { if (value == null) { throw new ArgumentNullException("value"); } return ToStabilityDesignMethod(value.ToString()); } /// /// Convert string to stability design method type. /// /// The value. /// internal static StabilityDesignMethod ToStabilityDesignMethod(string value) { if (string.IsNullOrEmpty(value) || value.Trim() == "") { throw new ArgumentException("value"); } var translationTable = new Dictionary { { "optimizedslopeandshoulderadaption", StabilityDesignMethod.OptimizedSlopeAndShoulderAdaption }, { "slopeadaptionbeforeshoulderadaption", StabilityDesignMethod.SlopeAdaptionBeforeShoulderAdaption } }; string key = value.ToLowerInvariant(); return key.ToEnumType(translationTable); } }