public static String Get(DslElement This, String Name, String Moniker) { try { return This.SelectSingleNode("p:" + Name).SelectSingleNode("p:" + Moniker, This.OwnerDocument.Manager).Attributes["Name"].Value; } catch (NullReferenceException) { return null; } }
public static void Set(DslElement This, String Name, String Moniker, String Value) { if (Value == null) { XmlNode node = This.SelectSingleNode("p:" + Name); if (node != null) This.Xml.RemoveChild(node); } else { XmlElement node = This.GetChildNode(Name + "/" + Moniker) as XmlElement; node.SetAttribute("Name", Value); } }
public DslElement Add(DslElement Node) { RootNode.AppendChild(Node.Xml); return Node; }
public void RemoveLinked(DslElement Node) { if (Node.Xml.HasAttribute("Name")) { MonikersCollection dcms = new MonikersCollection(Node.OwnerDocument, Node.Xml.Name); foreach (DslElement el in dcms) { if (el.References(Node)) { el.OwnerElement.DisposeLinked(); } } } Remove(Node); }
public void Remove(DslElement Node) { RootNode.RemoveChild(Node.Xml); }
public XmlNode GetChildNode(String xPath) { XmlNode node = null; DslElement e = this; foreach (String name in xPath.Split('/')) { node = e.GetChildNodeSimple(name); e = new DslElement(node as XmlElement); } return node; }
/// <summary>Ссылается ли данный узел на заданное имя. /// При этом мы считаем, что данный узел - моникер</summary> /// <param name="Name">Имя, которое хотим проверить</param> /// <returns>Ссылается или нет</returns> public bool References(DslElement Node) { String Name = Node.Xml.GetAttribute("Name"); if (Node.Xml.Name == "DomainProperty") { Name = (Node.Xml.ParentNode.ParentNode as XmlElement).GetAttribute("Name") + "[^a-zA-Z0-9]" + Name; } else if (Node.Xml.Name == "DomainClass" || Node.Xml.Name == "DomainRelationship") { return Name.Equals(Xml.GetAttribute("Name")); } Regex regex = new Regex("([^a-zA-Z0-9])" + Name + "([^a-zA-Z0-9])"); return regex.IsMatch("<" + Xml.GetAttribute("Name") + ">"); }