Fixing usless modifications of related items

This commit is contained in:
Zoe Roux 2021-01-25 20:50:18 +01:00
parent 3f5a0c060c
commit 5b9c82480e
2 changed files with 3 additions and 3 deletions

View File

@ -2,5 +2,6 @@ using System;
namespace Kyoo.Models.Attributes
{
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
public class EditableRelation : Attribute { }
}

View File

@ -231,10 +231,9 @@ namespace Kyoo.Controllers
foreach (PropertyInfo property in typeof(T).GetProperties()
.Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType)
&& !typeof(string).IsAssignableFrom(x.PropertyType)))
&& !typeof(string).IsAssignableFrom(x.PropertyType)
&& x.GetCustomAttribute<EditableRelation>() != null))
{
// TODO For DE classes (like ShowDE), the basic ienumerable should not be verified (for exemple, GenreLinks should be checked & not Genres).
Console.WriteLine($"Validating {property.Name}");
object value = property.GetValue(resource);
if (value == null || value is ICollection || Utility.IsOfGenericType(value, typeof(ICollection<>)))
continue;