SenseNet.ContentRepository.ContentNamingHelper.GetNewName C# (CSharp) Method

GetNewName() public static method

public static GetNewName ( string nameBase, ContentType type, Node parent ) : string
nameBase string
type SenseNet.ContentRepository.Schema.ContentType
parent Node
return string
        public static string GetNewName(string nameBase, ContentType type, Node parent)
        {
            var namewithext = EnforceRequiredExtension(nameBase, type);
            return namewithext;
        }
        public static string EnforceRequiredExtension(string nameBase, ContentType type)

Usage Example

Example #1
0
        public static Content CreateTemplated(Node parent, Node template, string nameBase)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (template == null)
            {
                throw new ArgumentNullException("template");
            }
            //if (nameBase == null) throw new ArgumentNullException("nameBase");

            using (var traceOperation = Logger.TraceOperation("Content.CreateTemplated"))
            {
                var name     = ContentNamingHelper.GetNewName(nameBase, ((GenericContent)template).GetContentType(), parent);
                var content  = Content.Create(ContentTemplate.CreateFromTemplate(parent, template, name));
                var realUser = (User)User.LoggedInUser;

                var now  = DateTime.UtcNow;
                var node = content.ContentHandler;
                node.CreatedBy        = realUser;
                node.VersionCreatedBy = realUser;
                node.NodeOperation    = NodeOperation.TemplateCreation;

                traceOperation.IsSuccessful = true;
                return(content);
            }
        }