using System; using System.Linq; using System.Xml.Linq; namespace Unosquare.Swan.Components { /// /// 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 => this.FindElement(nameof(this.PackageId))?.Value; /// /// Gets the name of the assembly. /// /// /// The name of the assembly. /// public String AssemblyName => this.FindElement(nameof(this.AssemblyName))?.Value; /// /// Gets the target frameworks. /// /// /// The target frameworks. /// public String TargetFrameworks => this.FindElement(nameof(this.TargetFrameworks))?.Value; /// /// Gets the target framework. /// /// /// The target framework. /// public String TargetFramework => this.FindElement(nameof(this.TargetFramework))?.Value; /// /// Gets the version. /// /// /// The version. /// public String Version => this.FindElement(nameof(this.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) => this._xmlDocument = xmlDocument; /// /// Finds the element. /// /// Name of the element. /// A XElement. protected XElement FindElement(String elementName) => this._xmlDocument.Descendants(elementName).FirstOrDefault(); } }