- pass cancellationToken where needed

pull/27/head
Simon G 5 years ago
parent 688ae81330
commit 11a1b9c828
  1. 4
      GBase/GBase.cs
  2. 5
      GBase/GBaseTable.cs
  3. 2
      GBase/Interfaces/IGBase.cs
  4. 3
      GBase/Interfaces/IGBaseTable.cs
  5. 8
      Test.GBase/GBaseIntegrationTest/Model.cs
  6. 8
      Test.GBase/GBaseTableIntegrationTest.cs

@ -118,13 +118,13 @@ namespace GBase
return Tables.Remove(table); return Tables.Remove(table);
} }
public async Task<bool> AddEntry<T>(T entry) where T : INotifyGBaseEntryChanged public async Task<bool> AddEntry<T>(T entry, CancellationToken cancellationToken) where T : INotifyGBaseEntryChanged
{ {
IGBaseTable<T> table = GetTable<T>(); IGBaseTable<T> table = GetTable<T>();
if (table == null) if (table == null)
throw new Exception(); //TODO: Create exception throw new Exception(); //TODO: Create exception
return await table.AddEntry(entry); return await table.AddEntry(entry, cancellationToken);
} }
/// <summary> /// <summary>

@ -118,13 +118,14 @@ namespace GBase
/// Add an entry that implements <see cref="INotifyGBaseEntryChanged"/> to this <see cref="IGBaseTable"/> /// Add an entry that implements <see cref="INotifyGBaseEntryChanged"/> to this <see cref="IGBaseTable"/>
/// </summary> /// </summary>
/// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param> /// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param>
/// <param name="cancellationToken"></param>
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
public async Task<bool> AddEntry(T entry) public async Task<bool> AddEntry(T entry, CancellationToken cancellationToken)
{ {
Entries.Add(entry); Entries.Add(entry);
entry.GBaseEntryChanged += OnGBaseEntryChanged; entry.GBaseEntryChanged += OnGBaseEntryChanged;
await _fileHandler.AddEntry(entry, this, TODO); await _fileHandler.AddEntry(entry, this, cancellationToken);
return true; return true;
} }

@ -58,6 +58,6 @@ namespace GBase.Interfaces
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
bool RemoveTable(IGBaseTable table); bool RemoveTable(IGBaseTable table);
Task<bool> AddEntry<T>(T entry) where T : INotifyGBaseEntryChanged; Task<bool> AddEntry<T>(T entry, CancellationToken cancellationToken) where T : INotifyGBaseEntryChanged;
} }
} }

@ -21,8 +21,9 @@ namespace GBase.Interfaces
/// Add an entry that implements <see cref="INotifyGBaseEntryChanged"/> to this <see cref="IGBaseTable"/> /// Add an entry that implements <see cref="INotifyGBaseEntryChanged"/> to this <see cref="IGBaseTable"/>
/// </summary> /// </summary>
/// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param> /// <param name="entry">The entry implementing <see cref="INotifyGBaseEntryChanged"/></param>
/// <param name="cancellationToken"></param>
/// <returns>True if successful, false if not</returns> /// <returns>True if successful, false if not</returns>
Task<bool> AddEntry(T entry); Task<bool> AddEntry(T entry, CancellationToken cancellationToken);
//T GetEntry(T entry); //TODO: This doesn't make sense... (passing instance of T to get the same instance back...) //T GetEntry(T entry); //TODO: This doesn't make sense... (passing instance of T to get the same instance back...)

@ -36,16 +36,16 @@ namespace Test.GBase.GBaseIntegrationTest
Groups = groupsTable.Entries; Groups = groupsTable.Entries;
} }
public void AddItem(IItem item) public void AddItem(IItem item, CancellationToken cancellationToken)
{ {
Items.Add(item); Items.Add(item);
_gBase.AddEntry(item); _gBase.AddEntry(item, cancellationToken);
} }
public void AddGroup(IGroup group) public void AddGroup(IGroup group, CancellationToken cancellationToken)
{ {
Groups.Add(group); Groups.Add(group);
_gBase.AddEntry(@group); _gBase.AddEntry(group, cancellationToken);
} }
} }
} }

@ -27,13 +27,15 @@ namespace Test.GBase
gBaseColumnFactoryMock.Setup(c => c.Create()).Returns(new GBaseColumn()); gBaseColumnFactoryMock.Setup(c => c.Create()).Returns(new GBaseColumn());
IGBaseTable<Foo> table = new GBaseTable<Foo>(fileHandlerFactoryMock.Object, gBaseColumnFactoryMock.Object); IGBaseTable<Foo> table = new GBaseTable<Foo>(fileHandlerFactoryMock.Object, gBaseColumnFactoryMock.Object);
table.Init(typeof(Foo), "", TODO, CancellationToken.None); table.Init(typeof(Foo), "", "", CancellationToken.None);
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
Foo foo = new Foo("Test"); Foo foo = new Foo("Test");
table.AddEntry(foo); table.AddEntry(foo, cancellationTokenSource.Token);
Foo foo2 = new Foo("Test2"); Foo foo2 = new Foo("Test2");
table.AddEntry(foo2); table.AddEntry(foo2, cancellationTokenSource.Token);
foo.Name = "Foo - ex Test"; foo.Name = "Foo - ex Test";
foo2.Name = "Some Name"; foo2.Name = "Some Name";

Loading…
Cancel
Save