Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

serialisation Xml dictionary

1 réponse
Avatar
klok
Bonjour,

j'utilise system.xml.serialize pour enregistrer ma classe
mais la propriété de type Dictionary<string,object>

comment faire?

voila la partie qui pose probleme
[XmlElement(typeof(Dictionary<string, cConnexion>))]
[XmlArray("CONNEXIONS", IsNullable = true)]
public Dictionary<string, cConnexion> connexions
{
get { return _connexions; }
set { _connexions = value; }
}


merci
florent

1 réponse

Avatar
Sasev2003
Bonjour,
un dictionnary ne peut pas être serialisé en XML avec .NET 2.0.
Néanmoins une astuce possible consisterais à créer un dictionnary
personnalisé implémentant une interface IXMLSerializable.
sasev.

"klok" wrote in message
news:
Bonjour,

j'utilise system.xml.serialize pour enregistrer ma classe
mais la propriété de type Dictionary<string,object>

comment faire?

voila la partie qui pose probleme
[XmlElement(typeof(Dictionary<string, cConnexion>))]
[XmlArray("CONNEXIONS", IsNullable = true)]
public Dictionary<string, cConnexion> connexions
{
get { return _connexions; }
set { _connexions = value; }
}


merci
florent