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