ScoobyRom.DataFile.RomXml.TryMergeWith C# (CSharp) Method

TryMergeWith() public method

public TryMergeWith ( IList toUpdate ) : int
toUpdate IList
return int
        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;
        }

Same methods

RomXml::TryMergeWith ( IList toUpdate ) : int