La sérialisation XML d'une liste d'attributs

J'ai une liste dans une autre liste (un produit avec des variantes). Je voudrais la liste des parents à avoir des attributs fixés sur elle (juste un id et un name).

De Sortie Désiré

<embellishments>
    <type id="1" name="bar bar foo">
        <row>
            <id>1</id>
            <name>foo bar</name>
            <cost>10</cost>
        </row>      
    </type> 
</embellishments>

Code Actuel

[XmlRoot( ElementName = "embellishments", IsNullable = false )]
public class EmbellishmentGroup
{
    [XmlArray(ElementName="type")]
    [XmlArrayItem("row", Type=typeof(Product))]
    public List<Product> List { get; set; }

    public EmbellishmentGroup() {
        List = new List<Product>();
        List.Add( new Product() { Id = 1, Name = "foo bar", Cost = 10m } );
    }
}

public class Product
{
    [XmlElement( "id" )]
    public int Id { get; set; }

    [XmlElement( "name" )]
    public string Name { get; set; }

    [XmlElement( "cost" )]
    public decimal Cost { get; set; }
}

Courant De Sortie

<embellishments>
    <type>
        <row>
            <id>1</id>
            <name>foo bar</name>
            <cost>10</cost>
        </row>
    </type>
</embellishments>

OriginalL'auteur Kieran | 2012-12-11