namespace Unosquare.Swan.Components
{
using System.Linq;
using System.Xml.Linq;
///
/// Represents a CsProj metadata abstract class
/// to use with CsProjFile parser.
///
public abstract class CsProjMetadataBase
{
private XDocument _xmlDocument;
///
/// Gets the package identifier.
///
///
/// The package identifier.
///
public string PackageId => FindElement(nameof(PackageId))?.Value;
///
/// Gets the name of the assembly.
///
///
/// The name of the assembly.
///
public string AssemblyName => FindElement(nameof(AssemblyName))?.Value;
///
/// Gets the target frameworks.
///
///
/// The target frameworks.
///
public string TargetFrameworks => FindElement(nameof(TargetFrameworks))?.Value;
///
/// Gets the target framework.
///
///
/// The target framework.
///
public string TargetFramework => FindElement(nameof(TargetFramework))?.Value;
///
/// Gets the version.
///
///
/// The version.
///
public string Version => FindElement(nameof(Version))?.Value;
///
/// Parses the cs proj tags.
///
/// The arguments.
public abstract void ParseCsProjTags(ref string[] args);
///
/// Sets the data.
///
/// The XML document.
public void SetData(XDocument xmlDocument) => _xmlDocument = xmlDocument;
///
/// Finds the element.
///
/// Name of the element.
/// A XElement.
protected XElement FindElement(string elementName) => _xmlDocument.Descendants(elementName).FirstOrDefault();
}
}