コード例 #1
0
        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)));

            }
        }
コード例 #2
0
ファイル: Migration.cs プロジェクト: RobertiF/Dynamo
        /// <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;
        }
コード例 #3
0
        public void AddTitle(XmlElement title)
        {
            XmlNode node = this.XmlDoc.GetElementsByTagName("titleset")[0];

            node.AppendChild(title.Clone());
        }
コード例 #4
0
ファイル: XmlRestructure.cs プロジェクト: gone3d/ortelius
        /// <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);
        }
コード例 #5
0
ファイル: CDAparser.cs プロジェクト: chaowarat/CDAparser
 public void setInnerTextEntry(XmlElement entry)
 {
     try
     {
         XmlNode section = this.document.SelectSingleNode("//component/component/section");
         section.AppendChild(entry.Clone());
     }
     catch (Exception) { }
 }