Thursday, February 17, 2011

Brunswick Zone Bowling

TFS2010 Object Model: TeamProjectPicker

the TFS 2010 object model provides a window to allow our users to select a TFS server, a collection project or a project.

The window is implemented by the class TeamProjectPicker Microsoft.TeamFoundation.Client which is in the namespace (assembly Microsoft.TeamFoundation.Client.dll).

TeamProjectPicker allows some flexibility because it can be used to select a collection project, a project or a series of projects.

Before looking at how we can achieve this, we see how the class is structured.

The class has three constructors that allow you to handle the possibility of choosing what to select and what credentials provider to use.

In particular, the most comprehensive manufacturer is as follows:

  1. Public Sub New ( ByVal mode As TeamProjectPickerMode ,
  2.                  ByVal disableCollectionChange As Boolean ,
  3.                  ByVal credentialsProvider As ICredentialsProvider )

L’argomento mode, di tipo TeamProjectPickerMode, permette di selezionare la modalità di selezione e può assumere i seguenti valori:

  • NoProject : You can select the server and project collection;
  • SingleProject : You can select only one project
  • multiproject: You can select multiple projects.

The following figure illustrates how the different options:

SNAGHTML11981afb

disableCollectionChange The argument allows you to decide whether it should be automatically selected collection of default (false) that can not be changed by the user or not (true).

Finally, the argument credentialsProvider used to set the credentials provider to use in case the connection a TFS non disponga di credenziali valide. Il provider da noi impostato verrà richiamato nel momento in cui , a causa della mancanza di credenziali, l’utente clicca sul link “Use different credentials”.

La GUI, una volta istanziata, può essere personalizzata (a dire il vero non molto) utilizzando le seguenti proprietà:

  • AcceptButtonText : permette di impostare il testo che appare sul bottone di selezione;
  • HelpTopic : permette di impostare l’argomento della guida relativo al dialog;
  • Text : permette di impostare la caption del controllo.

e può essere mostrata all’utente with ShowDialog (as usual dialog windows forms).

The class exposes, finally, the two properties to retrieve the collection selected by the user (type of property SelectedTeamProjectCollection TfsTeamProjectCollection) and projects (SelectedProjects type ProjectInfo).

The following piece of code displays the dialog selection in multi project and retrieves the user-selected values:

  1. Dim pp = New TeamProjectPicker ( TeamProjectPickerMode . Multiproject,
  2. False ,
  3. New UICredentialsProvider ())
  4. If pp.ShowDialog () = Windows.Forms. DialogResult . OK Then Dim
  5. collection = pp.SelectedTeamProjectCollection
  6. Dim projects = pp.SelectedProjects
  7. '
  8. ' Use collection of projects and
  9. '
  10. End If

Before concluding I would like to report the post SetDefaultSelectionProvider method whose purpose is to allow you to change the logic with which TeamProjectPicker the server recovers, the collection and projects by default.

object as an argument of the method is provided for any class that implements the interface ITeamProjectPickerDefaultSelectionProvider. The interface provides the following methods:

  • GetDefaultCollectionId : Returns the GUID of the collection default server which is Uri passt by subject;
  • GetDefaultProjects : Uri returns a list of projects relating to the collection where Guid is passed to argument;
  • GetDefaultServerUri : Returns the URI of the server default.

This allows us to customize the logic by which the picker selects and proposes projects to the user.

Finally, the picker is a Windows Forms object, so you must reference the System.Windows.Forms assembly.

Technorati tags: object model tfs, tfs 2010 ,

0 comments:

Post a Comment