Because XmlSerializer won't work on dictionaries, I use the XmlIgnore attribute on them, and use a mediating List<> property to render the dictionary as a list, which does work with serialization. However, my List<> property is ignored on deserialization. (There's no error thrown, and no serialization events are raised.) Why?
[XmlIgnore]
public Dictionary<string, string> ConnectionStrings { get; set; }
Here is the "surrogate" list property that is supposed to used for de/serialization. Like I say, this works on serialization, but the property is ignored during deserialization. I'm trying to understand why/what to do about it....
public List<ConnectionItem> SerializedConnections
{
get
{
return ConnectionStrings.Select(keyPair => new ConnectionItem() { Name = keyPair.Key, ConnectionString = keyPair.Value }).ToList();
}
set
{
ConnectionStrings = new Dictionary<string, string>();
foreach (var ci in value) ConnectionStrings.Add(ci.Name, ci.ConnectionString);
}
}
I tried setting a breakpoint in the set accessor of my SerializedConnections property, but it's never hit.