using System; using Deltares.Standard; using Deltares.Standard.IO.Xml; namespace Deltares.Stability { /// /// Repairs stability dike locations which had a 2D profile only /// public class StabilityDikeLocationXmlHandler : IXmlHandler { public bool CanHandle(Type type, string property) { return false; } public bool CanHandle(Type type) { return type == typeof(StabilityDikeLocationInfo); } public Type GetFormerPropertyType(Type type, string property) { return null; } public void Handle(object target, string property, object value, object[] objects) {} public void HandleObject(object target, object value) {} public void SetVersion(string version) {} public void Upgrade(object[] target) { foreach (var obj in target) { if (obj is StabilityDikeLocationInfo) { var dikeLocationInfo = (StabilityDikeLocationInfo) obj; if (dikeLocationInfo.StabilityModel != null && dikeLocationInfo.StabilityModel.SurfaceLine2 != null) { if (dikeLocationInfo.SchematizedSurfaceLine.Geometry.Points.Count == 0) { dikeLocationInfo.SchematizedSurfaceLine = dikeLocationInfo.StabilityModel.SurfaceLine2; } if (dikeLocationInfo.SurfaceLine.Points.Count == 0) { dikeLocationInfo.SurfaceLine = dikeLocationInfo.StabilityModel.SurfaceLine2.Geometry; } } } } } } }