GetAllowedChildTypeNames() public method

public GetAllowedChildTypeNames ( ) : IEnumerable
return IEnumerable
Example #1
0
        //====================================================================== Helper methods

        private static void AssertRestoreContentType(GenericContent targetParent, Node node)
        {
            if (targetParent == null || node == null)
            {
                throw new ArgumentNullException();
            }

            if (!(targetParent is IFolder))
            {
                throw new RestoreException(RestoreResultType.ForbiddenContentType, targetParent.Path);
            }

            var ctNames = targetParent.GetAllowedChildTypeNames().ToArray();

            if (ctNames.Length > 0 && !ctNames.Any(ctName => ctName == node.NodeType.Name))
            {
                throw new RestoreException(RestoreResultType.ForbiddenContentType, targetParent.Path);
            }
        }
Example #2
0
        private Exception GetNotAllowedContentTypeExceptionOnMove(Node node, GenericContent target)
        {
            var ancestor = target;

            while (ancestor.NodeType.Name == "Folder" || ancestor.NodeType.Name == "Page")
            {
                var p = ancestor.Parent as GenericContent;
                if (p == null)
                {
                    break;
                }
                ancestor = p;
            }

            var contentTypeName = node.NodeType.Name;

            return(new InvalidOperationException(String.Format("Cannot move the content '{0}' to '{1}' because target's ancestor does not allow the type '{2}'. Ancestor: {3} ({4}). Allowed types: {5}"
                                                               , node.Path, target.Path, contentTypeName, ancestor.Path, ancestor.NodeType.Name, String.Join(", ", target.GetAllowedChildTypeNames()))));
        }
Example #3
0
        private Exception GetNotAllowedContentTypeExceptionOnCreate(Node node, GenericContent parent)
        {
            var ancestor = parent;

            while (ancestor.NodeType.Name == "Folder" || ancestor.NodeType.Name == "Page")
            {
                var p = ancestor.Parent as GenericContent;
                if (p == null)
                {
                    break;
                }
                ancestor = p;
            }

            var contentTypeName = node.NodeType.Name;
            var nodePath        = String.Concat(node.Parent.Path, "/", node.Name);

            return(new InvalidOperationException(String.Format("Cannot save the content '{0}' because its ancestor does not allow the type '{1}'. Ancestor: {2} ({3}). Allowed types: {4}"
                                                               , nodePath, contentTypeName, ancestor.Path, ancestor.NodeType.Name, String.Join(", ", parent.GetAllowedChildTypeNames()))));
        }
Example #4
0
        //====================================================================== Helper methods

        private static void AssertRestoreContentType(GenericContent targetParent, Node node)
        {
            if (targetParent == null || node == null)
                throw new ArgumentNullException();

            if (!(targetParent is IFolder))
                throw new RestoreException(RestoreResultType.ForbiddenContentType, targetParent.Path);

            var ctNames = targetParent.GetAllowedChildTypeNames().ToArray();

            if (ctNames.Length > 0 && !ctNames.Any(ctName => ctName == node.NodeType.Name))
                throw new RestoreException(RestoreResultType.ForbiddenContentType, targetParent.Path);
        }
Example #5
0
        private Exception GetNotAllowedContentTypeExceptionOnMove(Node node, GenericContent target)
        {
            var ancestor = target;
            while (ancestor.NodeType.Name == "Folder" || ancestor.NodeType.Name == "Page")
            {
                var p = ancestor.Parent as GenericContent;
                if (p == null)
                    break;
                ancestor = p;
            }

            var contentTypeName = node.NodeType.Name;

            return new InvalidOperationException(String.Format("Cannot move the content '{0}' to '{1}' because target's ancestor does not allow the type '{2}'. Ancestor: {3} ({4}). Allowed types: {5}"
                , node.Path, target.Path, contentTypeName, ancestor.Path, ancestor.NodeType.Name, String.Join(", ", target.GetAllowedChildTypeNames())));
        }
Example #6
0
        private Exception GetNotAllowedContentTypeExceptionOnCreate(Node node, GenericContent parent)
        {
            var ancestor = parent;
            while (ancestor.NodeType.Name == "Folder" || ancestor.NodeType.Name == "Page")
            {
                var p = ancestor.Parent as GenericContent;
                if (p == null)
                    break;
                ancestor = p;
            }

            var contentTypeName = node.NodeType.Name;
            var nodePath = String.Concat(node.Parent.Path, "/", node.Name);

            return new InvalidOperationException(String.Format("Cannot save the content '{0}' because its ancestor does not allow the type '{1}'. Ancestor: {2} ({3}). Allowed types: {4}"
                , nodePath, contentTypeName, ancestor.Path, ancestor.NodeType.Name, String.Join(", ", parent.GetAllowedChildTypeNames())));
        }