Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Xml;
|
||||
|
||||
namespace aeqw89.tools.Publish;
|
||||
|
||||
internal class PropertyGroup {
|
||||
private readonly XmlElement _element;
|
||||
public PropertyGroup(XmlElement element) => _element = element;
|
||||
|
||||
public bool HasProperty(string name) => _element.SelectSingleNode($"./{name}") is XmlElement;
|
||||
|
||||
public string GetProperty(string name) {
|
||||
var node = _element.SelectSingleNode($"./{name}") as XmlElement;
|
||||
return node?.InnerText ?? string.Empty;
|
||||
}
|
||||
|
||||
public void SetProperty(string name, string value) {
|
||||
var node = _element.SelectSingleNode($"./{name}") as XmlElement;
|
||||
if (node == null) {
|
||||
node = _element.OwnerDocument!.CreateElement(name, _element.NamespaceURI);
|
||||
_element.AppendChild(node);
|
||||
}
|
||||
node.InnerText = value ?? string.Empty;
|
||||
}
|
||||
|
||||
public int Count => _element.ChildNodes.OfType<XmlElement>().Count();
|
||||
|
||||
public void Remove() => _element.ParentNode!.RemoveChild(_element);
|
||||
}
|
||||
Reference in New Issue
Block a user