From 3e0c0db79c171ffdad741a8f95e607ff3c19366d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 17 Feb 2021 22:53:31 +0100 Subject: [PATCH] Fixing the run generic method --- Kyoo.Common/Utility.cs | 3 ++- Kyoo.CommonAPI/LibraryManager.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Kyoo.Common/Utility.cs b/Kyoo.Common/Utility.cs index de63e968..dbbc400c 100644 --- a/Kyoo.Common/Utility.cs +++ b/Kyoo.Common/Utility.cs @@ -238,6 +238,8 @@ namespace Kyoo action(); yield break; } + + yield return enumerator.Current; while (enumerator.MoveNext()) yield return enumerator.Current; } @@ -254,7 +256,6 @@ namespace Kyoo .Where(x => { int i = 0; - // TODO this thing does not work. return x.GetGenericArguments().All(y => y.IsAssignableFrom(generics[i++])); }) .IfEmpty(() => throw new NullReferenceException($"No method {name} match the generics specified.")) diff --git a/Kyoo.CommonAPI/LibraryManager.cs b/Kyoo.CommonAPI/LibraryManager.cs index ecc38f5d..a6657be8 100644 --- a/Kyoo.CommonAPI/LibraryManager.cs +++ b/Kyoo.CommonAPI/LibraryManager.cs @@ -51,6 +51,8 @@ namespace Kyoo.Controllers if (!typeof(IEnumerable).IsAssignableFrom(typeof(T2))) return entry.Reference(member).LoadAsync(); + // TODO This is totally the wrong thing. We should run entry.Collection(collectionMember).LoadAsync() + // TODO where collectionMember would be member with T2 replaced by it's inner type (IEnumerable) Type collectionType = Utility.GetGenericDefinition(typeof(T2), typeof(IEnumerable<>)); return Utility.RunGenericMethod(entry, "Collection", collectionType, member).LoadAsync(); }