public int TryMergeWith(IList<Table2D> toUpdate)
{
Console.WriteLine ("Merging " + this.xml2D.Count.ToString () + " 2D XML items");
int count = 0;
foreach (Table2D table in xml2D) {
Table2D found = null;
int v;
v = table.Location;
if (v > 0) {
found = toUpdate.Where (t => t.Location == v).FirstOrDefault ();
} else {
v = table.RangeY.Pos;
found = toUpdate.Where (t => t.RangeY.Pos == v).FirstOrDefault ();
if (found == null) {
v = table.RangeX.Pos;
found = toUpdate.Where (t => t.RangeX.Pos == v).FirstOrDefault ();
}
}
// TODO add further match checking and conflict resolving
if (found != null) {
Merge (found, table);
++count;
} else
Console.Error.WriteLine ("Could not find this Table2D from XML: " + table.ToString ());
}
return count;
}