SenseNet.ContentRepository.GenericContent.CheckAllowedChildType C# (CSharp) Method

CheckAllowedChildType() private method

private CheckAllowedChildType ( Node node ) : TypeAllow
node Node
return TypeAllow
        internal TypeAllow CheckAllowedChildType(Node node)
        {
            var contentTypeName = node.NodeType.Name;

            //-- Ok if the new node is exactly TrashBag
            if (contentTypeName == "TrashBag")
                return TypeAllow.Allowed;

            //-- Ok if the new node is exactly SystemFolder and it is permitted
            if (contentTypeName == typeof(SystemFolder).Name)
            {
                var contentType = ContentType.GetByName(contentTypeName);
                if(contentType.Security.HasPermission(PermissionType.Open))
                    return TypeAllow.Allowed;
                return TypeAllow.TypeIsNotPermitted;
            }

            //-- Get parent if this is Folder or Page. Exit if current is SystemFolder or it is not a GenericContent
            var current = this;
            while (current != null && (current.NodeType.Name == "Folder" || current.NodeType.Name == "Page")) //HACK: using an object when it is unknown (Page)
                current = current.Parent as GenericContent;
            if (current != null && current.NodeType.Name == "SystemFolder")
                return TypeAllow.Allowed;
            if (current == null)
                return TypeAllow.Allowed;

            if(current.IsAllowedChildType(contentTypeName))
                return TypeAllow.Allowed;
            return TypeAllow.NotAllowed;
        }