Esempio n. 1
0
        /// <summary>
        /// Get the transitions for this <see cref="WorkItemType"/>
        /// </summary>
        private static List <StateTransition> GetTransitions(IWorkItemType workItemType)
        {
            List <StateTransition> currentTransitions;

            // See if this WorkItemType has already had it's transitions figured out.
            AllTransitions.TryGetValue(workItemType, out currentTransitions);
            if (currentTransitions != null)
            {
                return(currentTransitions);
            }

            // Get this worktype type as xml
            XmlDocument workItemTypeXml = workItemType.Export(false);

            // Create a dictionary to allow us to look up the "to" state using a "from" state.
            var newTransistions = new List <StateTransition>();

            // get the transitions node.
            XmlNodeList transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS");

            // As there is only one transitions item we can just get the first
            XmlNode transitions = transitionsList[0];

            // Iterate all the transitions
            foreach (XmlNode transitionXML in transitions.Cast <XmlNode>())
            {
                // See if we have this from state already.
                string          fromState  = transitionXML.Attributes["from"].Value;
                StateTransition transition = newTransistions.Find(trans => trans.From == fromState);
                if (transition != null)
                {
                    transition.To.Add(transitionXML.Attributes["to"].Value);
                }
                else
                {
                    // If we could not find this state already then add it.

                    // save off the transition (from first so we can look up state progression.
                    newTransistions.Add(new StateTransition
                    {
                        From = transitionXML.Attributes["from"].Value,
                        To   = new List <string> {
                            transitionXML.Attributes["to"].Value
                        }
                    });
                }
            }

            // Save off this transition so we don't do it again if it is needed.
            AllTransitions.Add(workItemType, newTransistions);

            return(newTransistions);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the transitions for this <see cref="WorkItemType"/>
        /// </summary>
        private static List<StateTransition> GetTransitions(IWorkItemType workItemType)
        {
            List<StateTransition> currentTransitions;

            // See if this WorkItemType has already had it's transitions figured out.
            AllTransitions.TryGetValue(workItemType, out currentTransitions);
            if (currentTransitions != null)
            {
                return currentTransitions;
            }

            // Get this worktype type as xml
            XmlDocument workItemTypeXml = workItemType.Export(false);

            // Create a dictionary to allow us to look up the "to" state using a "from" state.
            var newTransistions = new List<StateTransition>();

            // get the transitions node.
            XmlNodeList transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS");

            // As there is only one transitions item we can just get the first
            XmlNode transitions = transitionsList[0];

            // Iterate all the transitions
            foreach (XmlNode transitionXML in transitions.Cast<XmlNode>())
            {
                // See if we have this from state already.
                string fromState = transitionXML.Attributes["from"].Value;
                StateTransition transition = newTransistions.Find(trans => trans.From == fromState);
                if (transition != null)
                {
                    transition.To.Add(transitionXML.Attributes["to"].Value);
                }
                else
                {
                    // If we could not find this state already then add it.

                    // save off the transition (from first so we can look up state progression.
                    newTransistions.Add(new StateTransition
                    {
                        From = transitionXML.Attributes["from"].Value,
                        To = new List<string> { transitionXML.Attributes["to"].Value }
                    });
                }
            }

            // Save off this transition so we don't do it again if it is needed.
            AllTransitions.Add(workItemType, newTransistions);

            return newTransistions;
        }