Home > C#, TFS > TFS SDK: List the states of a WorkItemType

TFS SDK: List the states of a WorkItemType

Go to the TFS Content Page


The state of a WorkItemType are stored in the WorkItemType xml definition. You need to export it using the Export method as follow:

public static IList<string> GetStates(WorkItemType wit)
{
   XmlDocument doc = wit.Export(false);

   XmlNodeList nodes = doc.DocumentElement.SelectNodes("WORKITEMTYPE/WORKFLOW/STATES/STATE");
   List<string> list = new List<string>();
   foreach (XmlNode node in nodes)
   {
      string name = node.Attributes["value"].Value;
      if (!string.IsNullOrEmpty(name) && !list.Contains(name))
         list.Add(name);
   }
   return list;
}
Categories: C#, TFS
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: