예제 #1
0
        private void DoReplace(TwoDimArrayEntry source, TwoDimArrayEntry patch)
        {
            foreach (KeyValuePair <string, object> entry in patch.Values)
            {
                if (PatchColumns.Contains(entry.Key))
                {
                    continue;
                }

                if (!source.Values.ContainsKey(entry.Key))
                {
                    Console.WriteLine($"Source 2da does not contain column {entry.Key}, and will be skipped.");
                    continue;
                }

                source.Values[entry.Key] = entry.Value;
            }
        }
예제 #2
0
        private void DoAdd(TwoDimArray source, int index, TwoDimArrayEntry entryToAdd)
        {
            if (index < source.Entries.Count)
            {
                Console.WriteLine($"ADD patch entry at index {index} overwrites an existing value. Use REPLACE if replacement is intentional. Skipping...");
                return;
            }

            if (index > source.Entries.Count)
            {
                TwoDimArrayEntry padding = TwoDimArrayFactory.CreateEmptyEntry(source.Entries[0].Values.Keys);
                for (int i = source.Entries.Count - 1; i < index; i++)
                {
                    source.Entries.Add(padding);
                }
            }

            foreach (string column in PatchColumns)
            {
                entryToAdd.Values.Remove(column);
            }
            source.Entries.Add(entryToAdd);
        }