当前位置: 首页>>代码示例>>C#>>正文


C# DomNode.GetRoot方法代码示例

本文整理汇总了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;

        }
开发者ID:sbambach,项目名称:ATF,代码行数:10,代码来源:DynamicDomNode.cs

示例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];
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:25,代码来源:Tools.cs

示例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);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:13,代码来源:TestDomNode.cs

示例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;
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:24,代码来源:DomXmlWriter.cs

示例5: TestRootGetRoot

 public void TestRootGetRoot()
 {
     DomNodeType type = new DomNodeType("type");
     DomNode child = new DomNode(type);
     Assert.AreSame(child.GetRoot(), child);
 }
开发者ID:cococo111111,项目名称:ATF,代码行数:6,代码来源:TestDomNode.cs

示例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);
            }
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:23,代码来源:ReferenceValidator.cs

示例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);

            }
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:22,代码来源:ReferenceValidator.cs

示例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;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:21,代码来源:XmlPersister.cs

示例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;
        }
开发者ID:arsaccol,项目名称:SLED,代码行数:15,代码来源:SledSpfReaderWriter.cs


注:本文中的DomNode.GetRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。