TFS API – 有没有办法获得工作项类型的转换列表?

我试图从州“A”到州“X”。

有一些过渡阻止我去X.

我可以将WorkItemType导出为XML并对其进行处理,但在此之前,我想我会问是否有办法通过API获取Transitions。

SOOOO …..

没有多少人需要WorkItemTypes的转换。

好吧,我需要它,所以我写了一个方法来做到这一点。 在这里,万一其他人需要这个:

// Hold a list of all the transistions we have done. This will help us not have run them again If we already have. private static Dictionary> _allTransistions = new Dictionary>(); ///  /// Get the transitions for this  ///  ///  ///  private static List GetTransistions(this WorkItemType workItemType) { List currentTransistions; // See if this WorkItemType has already had it's transistions figured out. _allTransistions.TryGetValue(workItemType, out currentTransistions); if (currentTransistions != null) return currentTransistions; // 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(); // get the transistions node. XmlNodeList transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS"); // As there is only one transistions item we can just get the first XmlNode transitions = transitionsList[0]; // Iterate all the transitions foreach (XmlNode transition in transitions) { // save off the transistion newTransistions.Add(new Transition { From = transition.Attributes["from"].Value, To = transition.Attributes["to"].Value }); } // Save off this transition so we don't do it again if it is needed. _allTransistions.Add(workItemType, newTransistions); return newTransistions; } public class Transition { public string To { get; set; } public string From { get; set; } }