本文整理汇总了C#中DomNode.GetRoot方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.GetRoot方法的具体用法?C# DomNode.GetRoot怎么用?C# DomNode.GetRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomNode
的用法示例。
在下文中一共展示了DomNode.GetRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DynamicDomNode
public DynamicDomNode(DomNode node)
{
if (node == null)
throw new ArgumentNullException("node");
m_mgr = node.GetRoot().As<ExpressionManager>();
if (m_mgr == null)
throw new ArgumentException("node must be part of circuit");
m_node = node;
}
示例2: FindNode
/// <summary>
/// Finds DomNode with ID in tree containing give DomNode</summary>
/// <param name="id">ID to find</param>
/// <param name="domNode">DomNode in tree being searched</param>
/// <returns>DomNode with ID in tree containing give DomNode</returns>
public static DomNode FindNode(string id, DomNode domNode)
{
if (s_nodeDictionary == null || !s_lastRoot.Equals(domNode.GetRoot()))
{
s_nodeDictionary = new Dictionary<string, DomNode>();
s_lastRoot = domNode.GetRoot();
foreach (DomNode node in domNode.GetRoot().Subtree)
foreach (AttributeInfo attribute in node.Type.Attributes)
if (attribute.Name == "id")
{
string value = node.GetAttribute(attribute) as string;
if (!String.IsNullOrEmpty(value))
s_nodeDictionary[value] = node;
break;
}
}
return s_nodeDictionary[id];
}
示例3: TestDescendantGetRoot
public void TestDescendantGetRoot()
{
DomNodeType type = new DomNodeType("type");
ChildInfo childInfo = new ChildInfo("child", type, true);
type.Define(childInfo);
DomNode child = new DomNode(type);
DomNode parent = new DomNode(type);
DomNode grandparent = new DomNode(type);
parent.GetChildList(childInfo).Add(child);
grandparent.GetChildList(childInfo).Add(parent);
Assert.AreSame(child.GetRoot(), grandparent);
}
示例4: GetNodeReferenceString
/// <summary>
/// Converts a node to a string reference when writing</summary>
/// <param name="refNode">Node that is referenced</param>
/// <param name="root">Root node of data that is being written</param>
/// <param name="uri">URI of data that is being written</param>
/// <returns>String encoding the reference to the node</returns>
protected virtual string GetNodeReferenceString(DomNode refNode, DomNode root, Uri uri)
{
string id = refNode.GetId();
// if referenced node is in another resource, prepend URI
if (!refNode.IsDescendantOf(root))
{
DomNode nodeRoot = refNode.GetRoot();
IResource resource = nodeRoot.As<IResource>();
if (resource != null)
{
Uri relativeUri = uri.MakeRelativeUri(resource.Uri);
id = relativeUri + "#" + id;
}
}
return id;
}
示例5: TestRootGetRoot
public void TestRootGetRoot()
{
DomNodeType type = new DomNodeType("type");
DomNode child = new DomNode(type);
Assert.AreSame(child.GetRoot(), child);
}
示例6: RemoveReference
// removes refs from the tracker, and reports removed external refs
private void RemoveReference(DomNode owner, AttributeInfo attributeInfo, DomNode target)
{
List<Pair<DomNode, AttributeInfo>> referenceList;
if (m_nodeReferenceLists.TryGetValue(target, out referenceList))
{
referenceList.Remove(new Pair<DomNode, AttributeInfo>(owner, attributeInfo));
if (referenceList.Count == 0)
{
m_nodeReferenceLists.Remove(target);
}
}
// if target's root isn't the context's root, then it's an external reference
// that is being removed.
DomNode targetRoot = target.GetRoot();
if (DomNode != targetRoot)
{
ReferenceEventArgs e = new ReferenceEventArgs(owner, attributeInfo, target);
OnExternalReferenceRemoved(e);
ExternalReferenceRemoved.Raise(this, e);
}
}
示例7: AddReference
// adds refs to the tracker, and reports added external refs
private void AddReference(DomNode owner, AttributeInfo attributeInfo, DomNode target)
{
List<Pair<DomNode, AttributeInfo>> referenceList;
if (!m_nodeReferenceLists.TryGetValue(target, out referenceList))
{
referenceList = new List<Pair<DomNode, AttributeInfo>>();
m_nodeReferenceLists.Add(target, referenceList);
}
referenceList.Add(new Pair<DomNode, AttributeInfo>(owner, attributeInfo));
// if target's root isn't the context's root, then it's an external reference
// that is being added.
DomNode targetRoot = target.GetRoot();
if (DomNode != targetRoot)
{
ReferenceEventArgs e = new ReferenceEventArgs(owner, attributeInfo, target);
OnExternalReferenceAdded(e);
ExternalReferenceAdded.Raise(this, e);
}
}
示例8: GetNodeReferenceString
/// <summary>
/// Converts a node to a string reference when writing DomNode</summary>
/// <param name="refNode">Node that is referenced</param>
/// <param name="root">Root node of data that is being written</param>
/// <param name="uri">URI of data that is being written</param>
/// <returns>String encoding the reference to the node</returns>
protected virtual string GetNodeReferenceString(DomNode refNode, DomNode root, Uri uri)
{
string id = refNode.GetId();
// if referenced node is in another resource, prepend URI
DomNode nodeRoot = refNode.GetRoot();
if (nodeRoot != root)
{
IResource resource = nodeRoot.As<IResource>();
if (resource != null)
id = resource.Uri.LocalPath + "#" + id;
}
return id;
}
示例9: GetNodeReferenceString
private static string GetNodeReferenceString(DomNode refNode, DomNode root)
{
var id = refNode.GetId();
// if referenced node is in another resource, prepend URI
if (!refNode.IsDescendantOf(root))
{
var nodeRoot = refNode.GetRoot();
var resource = nodeRoot.As<IResource>();
if (resource != null)
id = resource.Uri.LocalPath + "#" + id;
}
return id;
}