diff --git a/GBase/GBaseTable.cs b/GBase/GBaseTable.cs index 7e19fe2..79fb80e 100644 --- a/GBase/GBaseTable.cs +++ b/GBase/GBaseTable.cs @@ -119,14 +119,46 @@ namespace GBase return Columns.Remove(column); } + private bool AddEntry(object entry) //TODO: Write to file + { + Entries.Add(entry); + return true; + } + + private bool ModifyEntry(object entry, string propertyName, object value) //TODO: Write to file + { + PropertyInfo property = entry.GetType().GetProperty(propertyName); + if (property == null) + return false; + + property.SetValue(entry, value); + return true; + } + + private bool RemoveEntry(object entry) //TODO: remove from file + { + if (!Entries.Contains(entry)) + return false; + + return Entries.Remove(entry); + } + /// /// A entry changed /// - /// The sender + /// The entry (sender) /// The - private void OnGBaseEntryChanged(object sender, GBaseEntryChangedEventArgs args) + private void OnGBaseEntryChanged(object entry, GBaseEntryChangedEventArgs args) { - //TODO: Implement function, depending on #23 + //TODO: Might change, depending on #23 + bool success; + if (!Entries.Contains(entry)) + success = AddEntry(entry); + else + success = ModifyEntry(entry, args.ColumnName, args.Value); + + if (!success) + throw new Exception("Failed to handle EntryChanged"); //TODO: Decide what to do here } ///