What steps will reproduce the problem?
1. Instanciate an Contact
2. Cast the PostalAddresses collection to IList<StructuredPostalAddress>
3. Save the contact
sample code:
Contact contact = new Contact();
contact.Name.GivenName = "toto";
IList<StructuredPostalAddress> addresses = contact.PostalAddresses;
StructuredPostalAddress address = new StructuredPostalAddress();
address.Country = "France";
addresses.Add(address);
// Save the contact
Explanation of the problem:
When whe cast the ExtensionCollection in IList<T>, if whe call the Add(T)
method, it calls the ICollection implementation which doesn't add the elemnt to
the container's Extensionelements collection.
To fix the problem I modified the ExtensionCollection class methods as
following:
public bool Remove(T value)
{
bool success = _items.Remove(value);
if ( success && this.container != null)
{
success &= this.container.ExtensionElements.Remove(value);
}
return success;
}
void ICollection<T>.Add(T item)
{
Add(item);
}
bool ICollection<T>.Remove(T item)
{
return Remove(item);
}
Original issue reported on code.google.com by mathieu....@ebp.com on 6 Jan 2011 at 2:34
Original issue reported on code.google.com by
mathieu....@ebp.com
on 6 Jan 2011 at 2:34