#25: throw missingTableException when getTable() doesn't find a matching table

pull/27/head
Simon G 5 years ago
parent b671d30d1d
commit 1df5d49287
  1. 7
      GBase/GBase.cs

@ -101,8 +101,9 @@ namespace GBase
if (Tables.OfType<IGBaseTable<T>>().Any())
return Tables.OfType<IGBaseTable<T>>().First();
//TODO: This probably doesn't work, because even though t.Type : T, IGBaseTable<t.Type> !: IGBaseTable<T>
return (IGBaseTable<T>) Tables.FirstOrDefault(t => typeof(T).IsAssignableFrom(t.Type)); //TestMe
throw new MissingTableException<T>();
// //TODO: This probably doesn't work, because even though t.Type : T, IGBaseTable<t.Type> !: IGBaseTable<T>
// return (IGBaseTable<T>) Convert.ChangeType(Tables.FirstOrDefault(t => typeof(T).IsAssignableFrom(t.Type)), typeof(IGBaseTable<T>)); //TestMe
}
/// <summary>
@ -149,7 +150,7 @@ namespace GBase
{
IGBaseTable<T> table = GetTable<T>();
if (table == null)
throw new Exception(); //TODO: Create exception
throw new MissingTableException<T>();
return await table.GetValues<TProperty>(entry, propertyName, cancellationToken);
}

Loading…
Cancel
Save