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)
|
|
|
|
|
{
|
|
|
|
|
var result = new List<Func<Type, bool>>();
|
|
|
|
|
|
|
|
|
|
var attributeObjects = fieldInfo.GetCustomAttributes(false);
|
|
|
|
|
foreach (var attributeObject in attributeObjects)
|
|
|
|
|
{
|
|
|
|
|
switch (attributeObject)
|
|
|
|
|
{
|
|
|
|
|
case SerializeReferenceUIRestrictionIncludeTypes includeTypes:
|
|
|
|
|
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsSubclassOrEqualOrHasInterface(includeTypes.Types));
|
|
|
|
|
continue;
|
|
|
|
|
case SerializeReferenceUIRestrictionExcludeTypes excludeTypes:
|
|
|
|
|
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsNotSubclassOrEqualOrHasInterface(excludeTypes.Types));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|