Exemplo n.º 1
0
        public void DeleteTest()
        {
            Assert.IsFalse(_modified.Records[1].IsDeleted);

            _modified.DeleteRecord(_modified.Records[1]);
            var diff = new DbfDiff(_original, _modified);

            Assert.IsTrue(diff.HasChanges);
            Assert.IsTrue(diff.Deleted.Count == 1);
        }
Exemplo n.º 2
0
        public void ApplyTo(Dbf dbf)
        {
            foreach (var record in Inserted)
            {
                dbf.Records.Add(record);
            }

            foreach (int index in Deleted)
            {
                dbf.DeleteRecord(index);
            }

            foreach (var kvp in Updated)
            {
                dbf.Records[kvp.Key] = kvp.Value;
                if (dbf.Fields.Any(f => f.Type == DbfFieldType.Memo))
                {
                    foreach (var field in dbf.Fields)
                    {
                        if (field.Type != DbfFieldType.Memo)
                        {
                            continue;
                        }

                        var memoEntry = kvp.Value[field.Name] as DbfMemoEntry;
                        if (!dbf.Memo.ContainsEntry(memoEntry))
                        {
                            // this is a new memo
                            kvp.Value[field.Name] = dbf.CreateMemoEntry(memoEntry.Value);
                        }
                    }
                }
            }

            Inserted.Clear();
            Updated.Clear();
            Deleted.Clear();
        }