如何获取TFS选项字段的选项列表?

如何获取TFS选项字段的选项列表?,tfs,tfs-sdk,Tfs,Tfs Sdk,我正在开发TFSAPI 2010 我想获得一个字段的可用选项列表来创建一个Combobox控件。例如: 优先级-->[1,2,3,4] 严重性-->['4-low'、'3-medium'、'2-height'、'1-Critical']您需要从TFS导出WorkItemType定义,然后在xml中找到字段并使用其中的值。下面是我用来获取转换列表的代码片段,如果您认为选项可能在全局列表中,那么您将在export方法中将标志设置为true public List<Transition&

我正在开发TFSAPI 2010

我想获得一个字段的可用选项列表来创建一个Combobox控件。例如:

优先级-->[1,2,3,4]
严重性-->['4-low'、'3-medium'、'2-height'、'1-Critical']

您需要从TFS导出WorkItemType定义,然后在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
}