Fixing the run generic method

This commit is contained in:
Zoe Roux 2021-02-17 22:53:31 +01:00
parent 8597cf34f2
commit 3e0c0db79c
2 changed files with 4 additions and 1 deletions

View File

@ -238,6 +238,8 @@ namespace Kyoo
action(); action();
yield break; yield break;
} }
yield return enumerator.Current;
while (enumerator.MoveNext()) while (enumerator.MoveNext())
yield return enumerator.Current; yield return enumerator.Current;
} }
@ -254,7 +256,6 @@ namespace Kyoo
.Where(x => .Where(x =>
{ {
int i = 0; int i = 0;
// TODO this thing does not work.
return x.GetGenericArguments().All(y => y.IsAssignableFrom(generics[i++])); return x.GetGenericArguments().All(y => y.IsAssignableFrom(generics[i++]));
}) })
.IfEmpty(() => throw new NullReferenceException($"No method {name} match the generics specified.")) .IfEmpty(() => throw new NullReferenceException($"No method {name} match the generics specified."))

View File

@ -51,6 +51,8 @@ namespace Kyoo.Controllers
if (!typeof(IEnumerable).IsAssignableFrom(typeof(T2))) if (!typeof(IEnumerable).IsAssignableFrom(typeof(T2)))
return entry.Reference(member).LoadAsync(); return entry.Reference(member).LoadAsync();
// TODO This is totally the wrong thing. We should run entry.Collection<T>(collectionMember).LoadAsync()
// TODO where collectionMember would be member with T2 replaced by it's inner type (IEnumerable<T3>)
Type collectionType = Utility.GetGenericDefinition(typeof(T2), typeof(IEnumerable<>)); Type collectionType = Utility.GetGenericDefinition(typeof(T2), typeof(IEnumerable<>));
return Utility.RunGenericMethod<CollectionEntry>(entry, "Collection", collectionType, member).LoadAsync(); return Utility.RunGenericMethod<CollectionEntry>(entry, "Collection", collectionType, member).LoadAsync();
} }