// 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 Deltares.Geotechnics;
using Deltares.Geotechnics.Converter;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Standard.IO.Xml;
using Deltares.Standard.Reflection;
namespace Deltares.Dam.Data.IO;
///
/// This handler is responsible for handling an object which has been created with the SurfaceLine type.
/// Since the old SurfaceLine has been refactored, this handler will convert the old SurfaceLine to a SurfaceLine2.
///
public class FailureMechanismeParamatersMStabXmlHandler : IXmlHandler
{
///
/// Not implemented for this class.
///
///
///
///
public void Handle(object target, string value, object[] objects)
{
throw new NotImplementedException();
}
public void SetVersion(string version) {}
///
/// This method returns true for a type and the
/// property.
///
/// The type to check for.
/// The property of the type to check for
/// True if type is and property is "SurfaceLine"
public bool CanHandle(Type type, string property)
{
return type == typeof(FailureMechanismeParamatersMStab) && property == StaticReflection.GetMemberName(x => x.SurfaceLine);
}
///
/// If the is an old and the is a
/// , the will be converted to the new
/// and the property is set for the target.
///
/// The target to set the handle the value for
/// The value to handle
public void HandleObject(object target, object value)
{
#pragma warning disable CS0618 // Type or member is obsolete
var oldSurfaceLine = value as BaseSurfaceLine;
#pragma warning restore CS0618 // Type or member is obsolete
if (null != oldSurfaceLine)
{
((FailureMechanismeParamatersMStab) target).SurfaceLine = (new OldSurfaceLineToNewConverter()).Convert(oldSurfaceLine);
}
}
public bool CanHandle(Type type)
{
return false;
}
public Type GetFormerPropertyType(Type type, string property)
{
return null;
}
public void Handle(object target, string property, object value, object[] objects) {}
public void Upgrade(object[] targets) {}
}