using System; using System.Xml; using Deltares.Geotechnics; using Deltares.Geotechnics.SurfaceLines; using Deltares.Standard.IO; using Deltares.Standard.Reflection; namespace Deltares.Stability { /// /// This factory creates a SurfaceLine instance if it is required by the XML definition /// This factory exists for backwards compatibility for SurfaceLine2 refactoring /// public class SurfaceLineInstanceFactory : IClassInstanceFactory { /// /// This method will return true for a type, false otherwise /// /// The type for which is checked whether this class can handle it. /// Returns true for type, false otherwise public bool CanHandle(Type type) { return type == typeof(SurfaceLine2); } /// /// Creates an instance of if the XMLNode is representing an old /// instance. If it is a new , a null is returned /// so the usual instance creation can take place. /// /// The type which would be initialized /// The XML node which contains information about the serialized instance /// An instance of SurfaceLine if the is a serialized /// SurfaceLine, null otherwise. public object CreateInstance(Type type, XmlNode node) { var attribute = node.Attributes[StaticReflection.GetMemberName(x => x.GeometryMustIncludePoint_Xml)]; return null == attribute ? new SurfaceLine() : null; } } }