2013-03-13 83 views

回答

0

您將需要從TFS中導出WorkItemType Definition,然後在xml中找到該字段並使用這些值。下面是我用來獲取轉換列表的代碼片段,如果您認爲這些選項可能位於全局列表中,那麼您將將export方法中的標誌設置爲true。

public List<Transition> GetTransistions(WorkItemType workItemType) 
    { 
     List<Transition> currentTransistions; 

     // See if this WorkItemType has already had it's transistions figured out. 
     this._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 newTransitions = new List<Transition>(); 

     // 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 transition in transitions) 
     { 
      // save off the transition 
      newTransitions.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. 
     this._allTransistions.Add(workItemType, newTransitions); 

     return newTransitions; 
    } 

過渡是一個小類,我有如下。

public class Transition 
{ 
    #region Public Properties 

    public string From { get; set; } 

    public string To { get; set; } 

    #endregion 
} 
相關問題