2020-05-16 15:17:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2020-05-16 19:15:24 +02:00
|
|
|
|
public static class SerializedReferenceUIDefaultTypeRestrictions
|
2020-05-16 15:17:04 +02:00
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<Func<Type, bool>> GetAllBuiltInTypeRestrictions(FieldInfo fieldInfo)
|
|
|
|
|
{
|
2022-12-28 14:03:46 +01:00
|
|
|
|
List<Func<Type, bool>> result = new List<Func<Type, bool>>();
|
|
|
|
|
|
|
|
|
|
object[] attributeObjects = fieldInfo.GetCustomAttributes(false);
|
|
|
|
|
foreach (object attributeObject in attributeObjects)
|
2020-05-16 15:17:04 +02:00
|
|
|
|
{
|
|
|
|
|
switch (attributeObject)
|
|
|
|
|
{
|
|
|
|
|
case SerializeReferenceUIRestrictionIncludeTypes includeTypes:
|
|
|
|
|
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsSubclassOrEqualOrHasInterface(includeTypes.Types));
|
|
|
|
|
continue;
|
|
|
|
|
case SerializeReferenceUIRestrictionExcludeTypes excludeTypes:
|
|
|
|
|
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsNotSubclassOrEqualOrHasInterface(excludeTypes.Types));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|