Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Contact addresses not saved #465

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
Thanks for the patch, I included it in rev. 1065.

Original comment by ccherub...@google.com on 25 Jan 2011 at 5:00