Andru's WebLog

//Comments about technology and software architecture
>MySelf.Persist();

September 2009 - Posts

Free (very good & useful) Telerik tools for TFS

Telerik has just released two new tools for TFS: Workitem Manager and Project Dashboard.

Here is the download link: http://www.telerik.com/products/tfsmanager-and-tfsdashboard.aspx

Check it out! We are using it and they are excellent. Hope they make this project a community one so we can continue to evolve and improve this excellent piece of software.

 Best regards, 

Andrés G Vettori, CTO, VMBC

www.vmbc.com

Posted: Sep 10 2009, 02:23 PM by andresv | with no comments
Filed under: , ,
XML Serialization of a Collection with properties

In this particular project we needed to serialize a collection of items and include an attribute in each one. Saddly, XmlSerializer seems to not support that directly but there is a workaround: use containment instead of derivation and then apply the [XmlElement] attribute to the collection property to get rid of the unwanted wrapping xml tag. For example:

 

A class derived from a collection class will XML-serialize only the collection, not any additional properties in your derived class.

public class NamedNodeList : List<Node>
{
    public string Name { get; set; } // ignored during XML serialization
}

The work-around is to use containment instead of derivation.

public class NamedNodeList
{
    public string Name { get; set; }
    public List<Node> Nodes { get; set; }
}

This works except you will get an additional wrapping element around the collection. To get rid of this wrapper, use the XmlElement attribute on the collection property.

[XmlElement]
public List<Node> Nodes { get; set; }

In fact, applying the XmlElement attribute to any collection member in any context (not just the derivation context here) will give you a collection not surrounded by a containing element.

 From the Chris Idzerda blog at http://blogs.vertigo.com/personal/chris/Blog/archive/2008/05/14/xml-serializing-a-derived-collection.aspx

 

More Posts