using System.Xml;
using System.Xml.Linq;
namespace OpenTap
{
/// Contains detailed information about something that occured while loading or saving information to an XML file.
public class XmlMessage
{
/// The XML element which caused the message. This may be null if no XML element could be associated with the message.
public virtual XElement Element { get; }
/// The message.
public virtual string Message {get; }
/// Creates an instance of XmlError. xmlElement may be null. message may be null if exception is set.
public XmlMessage(XElement xmlElement, string message)
{
Element = xmlElement;
Message = message;
}
/// Prints this message in a readable fashion.
public override string ToString()
{
string message = Message;
if (Element is IXmlLineInfo lineInfo && lineInfo.HasLineInfo())
return $"XML Line {lineInfo.LineNumber}: {message}";
return message;
}
}
}