formatting

This commit is contained in:
max
2022-12-28 14:03:46 +01:00
parent a0fa2c9b36
commit 0d04c50612
7 changed files with 72 additions and 62 deletions

View File

@ -6,10 +6,10 @@ public static class SerializedReferenceUIDefaultTypeRestrictions
{
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)
List<Func<Type, bool>> result = new List<Func<Type, bool>>();
object[] attributeObjects = fieldInfo.GetCustomAttributes(false);
foreach (object attributeObject in attributeObjects)
{
switch (attributeObject)
{

View File

@ -1,13 +1,10 @@
 using System;
using System;
using System.Linq;
public static class SerializeReferenceTypeRestrictionFilters
{
public static Func<Type, bool> TypeIsNotSubclassOrEqualOrHasInterface(Type[] types) => type =>
TypeIsSubclassOrEqualOrHasInterface(types).Invoke(type) == false;
public static Func<Type, bool> TypeIsSubclassOrEqualOrHasInterface(Type[] types) => type =>
types.Any(e => e.IsInterface ? TypeHasInterface(type, e) : TypeIsSubclassOrEqual(type, e));
public static Func<Type, bool> TypeIsNotSubclassOrEqualOrHasInterface(Type[] types) => type => TypeIsSubclassOrEqualOrHasInterface(types).Invoke(type) == false;
public static Func<Type, bool> TypeIsSubclassOrEqualOrHasInterface(Type[] types) => type => types.Any(e => e.IsInterface ? TypeHasInterface(type, e) : TypeIsSubclassOrEqual(type, e));
public static bool TypeIsSubclassOrEqual(Type type, Type comparator) => type.IsSubclassOf(comparator) || type == comparator;
public static bool TypeHasInterface(this Type type, Type comparator) => type.GetInterface(comparator.ToString()) != null;