public static bool CanHaveChildren(Type type) { for (var p = type; p != null; p = p.BaseType) { var a = ClassAttributes <AllowedChildrenTypes> .Get(p); if (a != null) { return(a.Types.Length > 0); } } return(false); }
public static bool ValidateComponentType(Type nodeType, Type componentType) { for (var t = componentType; t != null && t != typeof(NodeComponent); t = t.BaseType) { var a = ClassAttributes <AllowedComponentOwnerTypes> .Get(t); if (a != null) { return(a.Types.Any(ownerType => ownerType.IsAssignableFrom(nodeType))); } } return(true); }
static bool ValidateParentType(Type parentType, Type childType) { for (var p = childType; p != null; p = p.BaseType) { var a = ClassAttributes <AllowedParentTypes> .Get(p); if (a != null) { return(a.Types.Any(t => parentType == t || parentType.IsSubclassOf(t))); } } return(true); }
private static bool ValidateChildType(Type parentType, Type childType) { for (var p = parentType; p != null; p = p.BaseType) { var a = ClassAttributes <TangerineAllowedChildrenTypes> .Get(p); if (a != null) { return(a.Types.Any(t => childType == t || childType.IsSubclassOf(t))); } } return(false); }
public static bool IsPropertyReadOnly(this Widget widget, string property) => PropertyAttributes <TangerineReadOnlyAttribute> .Get(widget.GetType(), property) != null || (ClassAttributes <TangerineReadOnlyPropertiesAttribute> .Get(widget.GetType())?.Contains(property) ?? false);