コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public static bool IsPropertyReadOnly(this Widget widget, string property) =>
 PropertyAttributes <TangerineReadOnlyAttribute> .Get(widget.GetType(), property) != null ||
 (ClassAttributes <TangerineReadOnlyPropertiesAttribute> .Get(widget.GetType())?.Contains(property) ?? false);