﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;

namespace RWSE.Xml
{
    public interface IXmlSegment
    {
        /// <summary>
        /// The unique tag that contains data relating to this segment.
        /// </summary>
        string UniqueXmlTag { get; }

        /// <summary>
        /// Rebuilds class data into an XElement.
        /// </summary>
        /// <returns>The rebuild XElement.</returns>
        XElement Rebuild();

        /// <summary>
        /// Reads an XElement and processes the data, returning if the operation was a success. 
        /// </summary>
        /// <param name="element">The XmlReader to read from.</param>
        /// <returns>Returns true if the operation was a success.</returns>
        bool ReadFrom(XElement element);

        /// <summary>
        /// Reads from an XmlReader and processes the data, returning if the operation was a success. 
        /// </summary>
        /// <param name="reader">The XmlReader to read from.</param>
        /// <param name="search">Whether or not to search for the unique tag.</param>
        /// <returns>Returns true if the operation was a success.</returns>
        bool ReadFrom(XmlReader reader, bool search);
    }
}
