was published today (link ) the fourth article of the series dedicated to Team Foundation Server 2010 Object Model related to the handling of work items.
MVP Summit 2011 is over and I have just returned after a journey of nearly 18 hours ( between flights and expected).
The budget of the Summit is very positive: a week of full immersion in the Microsoft world to a place I always dreamed of visiting.
I met him in person MVP Italians who knew only through Facebook, Twitter and forums.
I saw almost 13 years after the legendary Enzino (only sin was not able to share more time with him but I hope to make my soon).
I personally knew the group RISE Contracts Code and in particular Francesco Logozzo (a great, and I thank you for your patience), Mike Barnett and Manuel Fähndrich . Enter the Building 99 (Research and Development) was an indescribable feeling.
Turn to the Microsoft campus was for me as a child to turn to DisneyWorld. Simply fascinating! At
end it was a very successful summit, which leaves me in the mouth, want to return. An experience at least once in their lifetime.
thank all those who have allowed this, and at this point, I will work hard to reconfirm the MVP in order to regain the ability to go back!
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:
L’argomento mode, di tipo TeamProjectPickerMode, permette di selezionare la modalità di selezione e può assumere i seguenti valori:
The following figure illustrates how the different options:
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à:
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:
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:
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.
Vi segnalo un post di Alessandro Del Sole in cui viene riportata la notizia che sono disponibili, sul sito di Lucian Wischik un insieme di esempi sulle funzionalità di Async attualmente in CTP.
L’indirizzo del sito è il seguente: AsyncSamplesSilverlight
 
La classe Assembly prevede il metodo GetReferencedAssembly() per recuperare l’elenco degli AssemblyName ralativi agli assembly referenziati da un determinato assembly.
The problem is that if we have a structure with more dll referenced in the chain, the method returns only the first level of the same chain.
Suppose we have the following structure:
or the project AssemblyExtension reference the dll AssemblyExtensionLIB1 which, in turn, reference the AssemblyExtensionLIB2.
In this case, the method GetReferencedAssembly (), applied to an assembly AssemblyExtension, returns the following list:
As you can see there is no trace of AssemblyExtensionLIB2. The following method
di estensione provvede ad eseguire un algoritmo ricorsivo per recuperare una lista di AssemblyName contenente tutte le reference dell’assembly:
The extension method is applicable on any assemble and the parameters are:
If your project before writing:
We get:
allowGacAssembly While if we set = false:
Attenzione: il metodo GetReferencedAssembly restituisce gli assembly effettivamente referenziati (cioè quelli per i quali c’è almeno un tipo utilizzato) e non quelli inseriti nelle referenze di Visual Studio.
 
In questo post vorrei porre l’attenzione su come utilizzare l’object model di TFS per gestire le Project Collection, cioè come utilizzare  da codice i servizi messi a disposizione dalla piattaforma TFS per creare, eseguire il detach o l’attach delle project collections del nostro server.
L’object model di TFS mette a disposizione l’interfaccia ITeamProjectCollectionService implementata da quelle classi che hanno la capacità di gestire le project collections.
Per prima cosa recuperiamo questa classe, utilizzando il metodo GetService (ereditato dalla classe TfsConnection) della TfsConfigurationServer:
dove tfs è un’istanza di TfsConfigurationServer ricavata tramite il seguente pezzo di codice:
Once recovered the service instance that implements ITeamProjectCollectionService we have a number of methods that allow us to "play" with the project collections.
methods of collection management projects are generally methods whose execution may not take long and that is why we introduce the concept of ServicingJobDetail and append operations.
In fact the method that we use for the creation of a project is the collection method QueueCreateCollection that "appends" the task of creating the collection and returns an object of type ServicingJobDetail we can ask to have knowledge of Avenza Dellea state ' transaction.
An example of code for creating a collection is as follows:
QueueCreateCollection version of the method we are using includes the following topics:
When we leave the previous method, we can stand waiting for the completion of the creation of the collection, with the methodology WaitForCollectionServicingToComplete. This will end when the transaction is complete and return an object of class TeamProjectCollection with information on the collection itself.
It 's interesting to observe the operation of creating the collection using the administrative console of TFS:
Another feature that we are examining is that of detach a collection project.
To run the detach a collection of projects is necessary to have the ol'istanza TeamProjectCollection or GUID of the collection and call the appropriate overload of the method QueueDetachCollection ITeamProjectCollectionService interface.
The following code snippet shows how to retrieve TeamProjectCollection a name from the collection of projects and run the detach:
Anche in questo caso, il metodo QueueDetachCollection restituisce un oggetto di classe ServicingJobDetail grazie al quale siamo in grado di comprendere quando l’operazione ha termine.
I parametri utilizzati nella chiamata al metodo di detach sono:
The inverse of a function to detach the collection is a project that allows you to attach a hook databese (containing a collection of projects) to TFS server.
The method used for this operation is QueueAttachCollection which provides a couple of simple overload of the piuù which has three parameters:
The following code snippet shows how to perform the attach of a collection given the connectionString:
Come visto in precedenza possiamo sfruttare il job restituito dal metodo di attach  per capire quando il lavoro è concluso.
Tra i metodi messi a disposizione dall’interfaccia vista in questo post abbiamo anche il metodo che può essere utilizzato per eseguire l’attach di un database di TFS precedente alla versione 2010.
A compendio di questo post vorrei allegare un esempio di console sviluppata con Visual Studio 2010 che permette di integrare le funzioni viste.
The console provides the name of the TFS server in the form http://server:8080/tfs, is passed as an argument.
In the previous post (link , link ) we saw how to use the TFS 2010 object model to connect to a TFS server and recover the project collection therein.
Niche In this post we will see ways to retrieve the properties of these projects within the project collections.
The first way is to use a mechanism similar to that seen in the previous post for the recovery of the collections based on the use of the method QueryChildren property CatalogNode:
In questo caso otteniamo una collezione in sola lettura di CatalogNode nella cui proprietà Resource sono presenti le proprietà del progetto (nome, descrizione, etc., etc.).
Poichè abbiamo utilizzato l’opzione IncludeParents, otteniamo che, per ogni catalogNode, la proprietà Parent contiene il nodo relativo alla collection di appartenenza.
Il parametro recurse=true nella precedente query è fondamentale in quanto i progetti non sono direttamente contenuti nel server.
Se mettiamo recurse=false otteniamo una collezione vuota.
Se volessimo ottenere i progetti contenuti in una specific collection, we could use a LINQ query like this:
Un altro modo per ottenere i progetti presenti all’interno di una collection è quello di eseguire una query sui nodi contenenti le risorse direttamente su un’istanza di TfsTeamProjectCollectionNel precedente post della serie, abbiamo visto i tre modi possibili per TfsTeamProjectCollection get an instance of the class. Suppose, then to have one and want to retrieve the properties of the projects in it:
In questo caso non serve la recursione e il recupero dei nodi padre perchè i progetti sono gerarchicamente disposti sotto la collection.
 
I must point out that the online event will be held on January 27 at 21:00. Speakers of the event will
Alessandro Del Sole and Renato Marzaro both MVP for Visual Basic, and a guarantee of quality.
For more info and registration at the event, refer to:
http://www.wpfitalia.it/Eventionline.aspx
In this post I will show how to recover and the information contained in the collection of Project Team Foundation Server using the Object Model messoci SDK available.
In the previous postseries we have seen how to connect to the TFS server, and then we take for granted being able to access the server.
To retrieve the collections of the project we can use the property CatalogNode TfsConfigurationServer class and perform a query to obtain the nodes of type Collection:
The variable collections contain a collection of read-only CatalogNode which are contained in the data we wanted. In particular
CatalogNode has a property of type Resource CatalogResource.
The most important properties of the class are CatalogeResource:
property CatalogNode a TfsConnection allows to obtain all the information relative ai nodi apparteneti alla connessione. Nel caso della TfsConfigurationServer si tratta di tuti gli oggetti contenuti nel server tra cui collection, progetti e via discorrendo.
Possiamo recuperare le informazioni contenute nella CatalogeNode anche avendo a disposizione l’istanza della Project Collection (cioè un’istannza della classe TfsTeamProjectCollection).
Prima di vedere come recuperare le informazioni di cui sopra vediamo come è possibile ottenere l’istanza della TFSTeamProjectCollection.
Se abbiamo a disposizione un’istanza della TfsConfigurationServer (vedi il post precedente), possiamo utilizzare il metodo GetTeamProjectCollection.
The method provides, as an argument, the instance identifier of the collection you want to retrieve. This is a GUID that is recoverable in the Properties property of the collection CatalogeResource instance with key "instanceId"
E’ evidente che se non abbiamo l’instance identifier e dobbiamo recuperarlo con il precedente pezzo di codice, abbiamo anche tutte le informazioni culla collection senza dover utilizzare l’istanza di TfsTeamProjectCollection ottenuta con il metodo GetTeamProjectCollection.
Supponiamo, per un attimo, di avere l’instace id senza dover accedere ai nodi della CatalogeNode dell’istanza di TfsConfigurationServer. In questo caso, per ottenere l’istanza di TfsTeamProjectCollection è sufficiente:
where instanceId is the string that identifies the instance of the Id collection.
GetTeamProjectCollection method behaves similarly to what we saw in the previous TfsConfigurationServerFactory post :
Two other ways to retrieve the instance of TfsTeamProjectCollection are
We observe that the URL of the collection is obtained by concatenating the name of the server URL colection.
If we use the factory, we will get the same instance of TfsTeamProjectCollection, while the manufacturer allows us to have a different instance each time.
When we have the instance to access the server component of the project collection, the same information can be recovered by going directly to the property and in particular to the property CatalogNode Resource:
Another way to retrieve information relating to the collection in our server is to require TfsConfigurationServer instance, the service ITeamProjectCollectionService through education:
and then invoke the method GetCollections:
The result of this is a IList (Of TeamProjectCollection). The TeamProjectCollection is a class in this namespace Microsoft.TeamFoundation.Framework.Client and contains information relating to the collection project and a bit more.
E 'a while that I post to "vent" and it's time to make a!
Today I happened to read some comments related to WP7, which said that the operating system has not found favor with the public because they are too simple to be boring!
Since the ease of use means that a product does not meet public favor ?!?!?!?!
We complained about why Windows Mobile complex, slow, cumbersome, etc.. Etc.. and now this is too easy to use ?!?!?!
I have given up the phone to my wife who does not love the technology and using a telephone in which the maximum dell'avveniristico is the MMS and was able to use it without an engineering degree Nuclear! It has not even filed for divorce because they are bought me!!
If WP7 did not find the expected success is not due to the fact that it is simple to use! The fact that the interface is minimal can be worn as a downside: can like it or not, but it is a negative side!
That said, personally I enjoy like a hedgehog to read the mail with a few taps of your finger, you think of it as you like!
E 'output in the February issue of ioProgrammo , an introduction to my article on the Contracts Code.
Because of the work I am busy lately to interact, via code, using the object model, with TFS . I would like to start a mini series dedicated to tips and short articles on the use of certain classes in the same object model. The series is not meant to be exhaustive but is intended as my habit of sharing know-how.
This post covers the initial part of every interaction with TFS: The connection to the server.
If we want to create client applications that interact with Team Foundation Server 2010, we can use the object model made available by libraries Microsoft.TeamFoundation .*. dll.
In particular to connect to the server you need to reference libraries and Microsoft.TeamFoundation.Client.dll Microsoft.TeamFoundation.Common.dll.
The connection to the TFS server (in order to obtain services for the management of the entity's own server) can be done using the class contained within the namespace TFSConfigurationServer Microsoft.TeamFoundation.Client (Microsoft.TeamFoundation.Client assembly. dll).
E 'can create an instance of TFSConfigurationServer in two ways: Using the manufacturer
In both cases the address http://server:8080 / tfs must be a valid address to connect to TFS. We can get the address using the Team Explorer. And 'Just open the properties of a collection of Team Explorer to get the address to be included in our classrooms:
Both manufacturer who make available factory overload to specify the login credentials, but at this time, non ce ne preoccupiamo e come provider di credenziali utilizziamo la classe UICredentialProvider che permette, se TfsConfigurationServer non trova delle credenziali in cache, di richiederle all’utente con un prompt.
Quello che ci interessa in questo post è mettere in evidenza la sostanziale differenza tra costruttore e factory e cioè il fatto che il costruttore permette di ottenere differenti istanze di conessione  (una per ogni New) mentre la factory crea una nuova istanza la prima volta che viene richiamato il metodo GetConfigurationServer e restituisce la stessa istanza le volte successive.
Per verificare questo non possimao utilizzare il metodo Equals delal classe Object perchè tale metodo e ridefinito in the class from which the TfsConnection TfsConfigurationServer comes to compare two instances of the class defined as equal when they have the same URL. Then write the following code:
Following the call to the Dispose method, if the instances are distinct, tfsInstance1 will be "provisions" while tfsInstance2 not.
To test this we insert the QuickWatch in our project to highlight the Disposed property values \u200b\u200b(which are not directly visible because Friend) and we observe that, after Dispose has:
Let the same thing for the instances generated by the Factory:
In this case, tell us QuickWatch:
If this were not enough, we can analyze GetConfigeurationServer is implemented as the method of using TfsConfigurationServerFactory Reflector :
The class implements a sort of cache (this is a Dictionary (Of Uri, TfsConfigurationServer)) in which it is sought any instance already created ( Step 1) and, in this case it is returned. If there is an instance for the URI passed as an argument, the factory uses the constructor to instantiate a new TfsConfigurationServer and stores in its cache (step 2).
The Visual Basic team, adhering to the requests made by the developer community VB.NET (Which, in spite of the C-sharpisti is large and vital
), published a series of examples ranging from 7 to Phone Windows Azure.
You can find the complete list at this link .
also found on the pages indicated wishlist VB code, or the ability to tell the VB team to an article or a snippet of code that you want to appear in the examples.
This post is a continuation of previous post serialization.
In particular we will see that the SOAP and JSON serialization.
Serialization SOAP SOAP serialization is committed to the SoapFormatter System.Runtime.Serialization.Formatters.Soap contained in the namespace in the library of the same name. The SOAP formatter
goes back to the earliest versions of the framework and, unfortunately, from a certain point, even though it was declared obsolete, it was not brought forward in the development and does not support certain types of data very much used in the world. NET such as generics and nullable.
For this reason, we can not serialize in SOAP format (using the SoapFormatter) our bill (see previous post) as this has a property of type List (Of DettagliFattura) (generic).
JSON serialization format JSON serialization (more info here ) is a textual format very popular in AJAX applications. Entry is a way to serialize complex objects even with a very compact size and easy to interoperate with JavaScript, therefore, well suited for scenarios partoicolarmente AJAX-style web.
JSON serialization can be done using the class DataContractJsonSerializer that framework 4.0 is contained in the namespace System.Runtime.Serialization.Json all’interno dell’omonimo assembly.
Fate attenzione perchè, se state sviluppando per il framework 3.5 (prima di questo la classe DataContractJsonSerialization non era presente), trovate la classe nello stesso namespace ma l’assembly è System.ServiceModel.Web.
La classe DataContractJsonSerializer prevede, tra i vari metodi, WriteObject e ReadObject che permettono , rispettivamente, di serializzare e deserializzare un’oggetto in formato JSON.
Entrambi i metodi sfruttano uno stream per serializzare l’oggetto. In base alle nostre esigenze tale stream potrebbe essere in memoria (come nell’esempio riportato in seguito), su file o su un canale web (ad esempio come response to a request from a remote client).
methods for serialization and deserialization of the object are Invoice:
The result is as follows:
We observe that, in the examples, we used the default encoding for strings. Evidently, if necessary, the encoding may be the one we want.
If our class (as in Bill) is composed of objects. NET serializable, we can immediately use the JSON serialization.
Alternatively, we can decorate our class (and all those that may be used as a property) with the Serializable attribute or the attribute DataContract.
In the first case it is enough to decorate the sun and JSON serialization classes will have the properties expressed by the name of the attribute that is encapsulated by private property. In the case of property definite in modo compatto (come accade nella Fattura) il compilatore crea, dietro le quinte un attributo per ogni proprietà con lo stesso nome della proprietà a cui viene anteposto il carattere “_”. In questo caso il JSON risultante vedrà le proprietà espresse con il nome della proprietà preceduta da “_”.
Nel caso dell’attributo DataContract, invece, è necessario decorare anche ogni proprietà con l’attributo DataMember (se una proprietà non viene decorata con DataMember, questa non finisce nella serializzazione).
L’attributo DataMember permette di rinominare la proprietà all’interno del JSON risultante:
In this case, the properties, the ' inside of the JSON, will be called "numeroDocumento" and not "NumeroDocumento.
using DataContract and DataMember we can intervene in the resulting JSON in order to customize the results to our liking (especially useful when we are given the path and we must re-create the class).
Just a hint at the possibility of creating a custom serialization of objects.
To do this, the framework provides us with the interface that has two IFormatter Serialize and Deserialize methods that we have to redefine our logic by implementing the serialization / deserialization:
An example might be: