public void Combine(CommitWork work)
{
// New objects can't possibly be in more than one UOW,
// so just add all of them.
foreach (KeyValuePair<Guid, byte[]> newby in work.Newbies)
Newbies.Add(newby.Key, newby.Value);
foreach (KeyValuePair<Guid, byte[]> dirtball in work.Dirtballs)
{
if (Newbies.ContainsKey(dirtball.Key))
// use the updated XML string from the dirtball if it is new
Newbies[dirtball.Key] = dirtball.Value;
else
// otherwise the newer modifications trump the older modifications
Dirtballs[dirtball.Key] = dirtball.Value;
}
foreach (Guid gonerId in work.Goners)
{
// Deleting trumps modified.
Dirtballs.Remove(gonerId);
// Only add it to deleted list, if it is *not* in the new list.
// An object that is both new and deleted has not been saved in the store,
// so no further action is needed.
if (!Newbies.Remove(gonerId))
Goners.Add(gonerId);
}
// just use the latest list of custom fields
CustomFields = work.CustomFields;
}
}