using System; using Deltares.Geotechnics; using Deltares.Geotechnics.Converter; using Deltares.Geotechnics.SurfaceLines; using Deltares.Standard; 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 { 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); } /// /// Not implemented for this class. /// /// /// /// public void Handle(object target, string value, object[] objects) { throw new NotImplementedException(); } /// /// 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) { var oldSurfaceLine = value as BaseSurfaceLine; 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) { } } }