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


C# XmlElement.Clone方法代码示例

本文整理汇总了C#中System.Xml.XmlElement.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.Clone方法的具体用法?C# XmlElement.Clone怎么用?C# XmlElement.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlElement的用法示例。


在下文中一共展示了XmlElement.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorkItemTypeDefinition

        public WorkItemTypeDefinition(XmlElement witdElement, bool isWritable)
        {
            if (witdElement.SelectSingleNode("WORKITEMTYPE") == null)
            {
                throw new ArgumentException("Invalid definition document, missing WORKITEMTYPE element.");
            }

            _witdElement = (XmlElement)witdElement.Clone();
            _isWritable = isWritable;

            if (!_isWritable)
            {
                _fields = _witdElement
                    .SelectNodes("WORKITEMTYPE/FIELDS/FIELD")
                    .Cast<XmlElement>()
                    .Select(e => new WitdField(e))
                    .ToArray();

                _states = _witdElement
                    .SelectNodes("WORKITEMTYPE/WORKFLOW/STATES/STATE")
                    .Cast<XmlElement>()
                    .Select(e => new WitdState(e))
                    .ToArray();

                _transitions = new HashSet<WitdTransition>(witdElement
                                                               .SelectNodes("WORKITEMTYPE/WORKFLOW/TRANSITIONS/TRANSITION")
                                                               .Cast<XmlElement>()
                                                               .Select(e => new WitdTransition(e)));

            }
        }
开发者ID:halvsvenskeren,项目名称:WitMorph,代码行数:31,代码来源:WorkItemTypeDefinition.cs

示例2: CreateDummyNode

        /// <summary>
        /// Call this method to create a dummy node, should a node failed to be 
        /// migrated. This results in a dummy node with a description of what the 
        /// original node type was, and also retain the number of input and output
        /// ports.
        /// </summary>
        /// <param name="element">XmlElement representing the original node which
        /// has failed migration.</param>
        /// <param name="inportCount">The number of input ports required on the 
        /// new dummy node. This number must be a positive number greater or 
        /// equal to zero.</param>
        /// <param name="outportCount">The number of output ports required on the 
        /// new dummy node. This number must be a positive number greater or 
        /// equal to zero.</param>
        /// <returns>Returns a new XmlElement representing the dummy node.</returns>
        /// 
        public static XmlElement CreateDummyNode(
            XmlElement element, int inportCount, int outportCount)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            if (inportCount < 0 || (outportCount < 0))
            {
                var message = "Argument value must be equal or larger than zero";
                throw new ArgumentException(message, "inportCount/outportCount");
            }

            var dummyNodeName = "DSCoreNodesUI.DummyNode";
            XmlDocument document = element.OwnerDocument;
            XmlElement dummy = document.CreateElement(dummyNodeName);

            foreach (XmlAttribute attribute in element.Attributes)
                dummy.SetAttribute(attribute.Name, attribute.Value);

            dummy.SetAttribute("type", dummyNodeName);
            dummy.SetAttribute("legacyNodeName", element.GetAttribute("type"));
            dummy.SetAttribute("inputCount", inportCount.ToString());
            dummy.SetAttribute("outputCount", outportCount.ToString());
            dummy.SetAttribute("nodeNature", "Deprecated");

            XmlElement originalNode = document.CreateElement("OriginalNodeContent");

            //clone a copy of the original node
            XmlElement nodeContent = (XmlElement)element.Clone();

            //append the original node content as a child of the dummy node
            originalNode.AppendChild(nodeContent);
            dummy.AppendChild(originalNode);

            return dummy;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:52,代码来源:Migration.cs

示例3: AddTitle

        public void AddTitle(XmlElement title)
        {
            XmlNode node = this.XmlDoc.GetElementsByTagName("titleset")[0];

            node.AppendChild(title.Clone());
        }
开发者ID:majorsilence,项目名称:LibDvdAuthor,代码行数:6,代码来源:DvdAuthor.cs

示例4: addInheritedElements

        /// <summary>
        /// 
        /// </summary
        private void addInheritedElements(XmlElement classNode,string superClassName)
        {
            //ugly hack to make sure superClassNode isen't null
            XmlNode superClassNode = classNode.Clone();

            testCounter++;
            bool succes = false;
            XmlNodeList classes = contentCloneXml.SelectNodes("class");
            testCounter++;

            //find the super class in xml
            foreach(XmlElement testClass in classes){
                testCounter++;
                string testClassName="";
                if(testClass.SelectSingleNode("package")!=null && testClass.SelectSingleNode("name")!=null){
                    testClassName =testClass.SelectSingleNode("package").InnerText+"."+testClass.SelectSingleNode("name").InnerText;
                }

                if(testClassName == superClassName){
                    succes = true;
                    superClassNode =  testClass;
                }
            }

            XmlNode inherHieraElement = classNode.SelectSingleNode("inheritanceHierarchy");
            XmlElement inHieraNode = documentationXml.CreateElement("inheritanceClass");

            if(!succes){
                inHieraNode.SetAttribute("fullPath","#"+superClassName);
                inHieraNode.InnerText = superClassName.Substring(superClassName.LastIndexOf(".")+1);
                inherHieraElement.AppendChild(inHieraNode);
                //the extended class dosent exist in the in the documentation
                return;
            }

            inHieraNode.SetAttribute("fullPath",superClassName);
            inHieraNode.InnerText = superClassName.Substring(superClassName.LastIndexOf(".")+1);
            inherHieraElement.AppendChild(inHieraNode);

            XmlNodeList elements = superClassNode.SelectNodes("method[@access = 'public'] | method[@access = 'protected'] | method[@access = 'internal'] | property[@access = 'public'] | property[@access = 'protected'] | property[@access = 'internal']");

            foreach(XmlElement elementNode in elements){
                //dont copy constructor of super class
                string elementNodeName = elementNode.SelectSingleNode("name").InnerText;

                if(superClassNode.SelectSingleNode("name").InnerText != elementNodeName){

                    elementNode.SetAttribute("inherited","true");
                    elementNode.SetAttribute("inheritedFrom",superClassName);

                    //Dont add if the element already exists
                    XmlNodeList originalElements = classNode.SelectNodes("method[name = '"+elementNodeName+"'] | property[name = '"+elementNodeName+"']");
                    if(originalElements.Count == 0) classNode.AppendChild(elementNode.Clone());
                    else {
                        //the element exist
                        string rwSuper = elementNode.GetAttribute("readWrite");
                        string rwSub = ((XmlElement) originalElements[0]).GetAttribute("readWrite");
                        if(rwSub != "ReadWrite" && rwSuper != rwSub) ((XmlElement) originalElements[0]).SetAttribute("readWrite","ReadWrite");
                    }
                }

            }

            //add elements thats extends the superClass
            string superSuperClass = getExtendClassPath(superClassNode);
            if(superSuperClass!="") addInheritedElements((XmlElement) classNode,superSuperClass);
        }
开发者ID:gone3d,项目名称:ortelius,代码行数:70,代码来源:XmlRestructure.cs

示例5: setInnerTextEntry

 public void setInnerTextEntry(XmlElement entry)
 {
     try
     {
         XmlNode section = this.document.SelectSingleNode("//component/component/section");
         section.AppendChild(entry.Clone());
     }
     catch (Exception) { }
 }
开发者ID:chaowarat,项目名称:CDAparser,代码行数:9,代码来源:CDAparser.cs


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