mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Added support for embedding lists of IEmbeddedDocument types.
This commit is contained in:
parent
b16d85d0fc
commit
57120c9eeb
4 changed files with 75 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Marr.Data.Mapping;
|
||||
|
@ -29,7 +30,14 @@ namespace NzbDrone.Core.Datastore
|
|||
return true;
|
||||
}
|
||||
|
||||
return propertyInfo.CanRead && propertyInfo.CanWrite && IsSimpleType(propertyInfo.PropertyType);
|
||||
if (typeof(IEnumerable<IEmbeddedDocument>).IsAssignableFrom(propertyInfo.PropertyType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var result = propertyInfo.IsReadable() && propertyInfo.IsWritable() && IsSimpleType(propertyInfo.PropertyType);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool IsSimpleType(Type type)
|
||||
|
@ -45,5 +53,15 @@ namespace NzbDrone.Core.Datastore
|
|||
|| type == typeof(DateTime)
|
||||
|| type == typeof(Decimal);
|
||||
}
|
||||
|
||||
private static bool IsReadable(this PropertyInfo propertyInfo)
|
||||
{
|
||||
return propertyInfo.CanRead && propertyInfo.GetGetMethod(false) != null;
|
||||
}
|
||||
|
||||
private static bool IsWritable(this PropertyInfo propertyInfo)
|
||||
{
|
||||
return propertyInfo.CanWrite && propertyInfo.GetSetMethod(false) != null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue