public virtual void TransformPropertyNames(RawContent raw)
 {
     foreach (var property in raw.Property)
     {
         property.Name = _memberNameValidator.CreateIdentifier(property.Name);
     }
 }
示例#2
0
        private string CalculateNamespace(ContentType contentType)
        {
            var ns = new List <string>();

            // Group namespace
            if (_options.IncludeGroupNameInNamespace && !string.IsNullOrEmpty(contentType.GroupName))
            {
                var groupNs = _memberNameValidator.CreateIdentifier(contentType.GroupName);
                ns.Add(groupNs);
            }

            // Type namespace
            switch (contentType.ContentTypeCategory)
            {
            case ContentTypeCategory.Page:
                ns.Add(_options.PageNamespace);
                break;

            case ContentTypeCategory.Block:
                ns.Add(_options.BlockNamespace);
                break;

            default:
                break;
            }

            return(string.Join(".", ns));
        }
示例#3
0
        public virtual PropertyDefinition Map(PageDefinition pageDefinition)
        {
            var propertyDefinition = new PropertyDefinition
            {
                Name             = _memberNameValidator.CreateIdentifier(pageDefinition.Name),
                DisplayEditUI    = pageDefinition.DisplayEditUI,
                EditCaption      = pageDefinition.EditCaption,
                FieldOrder       = pageDefinition.FieldOrder,
                HelpText         = pageDefinition.HelpText,
                LanguageSpecific = pageDefinition.LanguageSpecific,
                Required         = pageDefinition.Required,
                Searchable       = pageDefinition.Searchable,
                GroupName        = MapGroupName(pageDefinition.Tab.Name),
                Type             = MapType(pageDefinition.Type)
            };

            ModifyComposerPropertyTypes(pageDefinition, propertyDefinition);

            return(propertyDefinition);
        }
        public string CreateContentTypeIdentifier(string typeName, ContentTypeCategory category, out string groupName)
        {
            if (string.IsNullOrEmpty(typeName))
            {
                groupName = null;
                return(typeName);
            }

            // Check for names that includes a group name, e.g. "[Group name] Page name"
            typeName = RemoveGroupName(typeName, out groupName);

            // Ensure that the type name end with provided suffix
            string suffix = null;

            switch (category)
            {
            case ContentTypeCategory.Page:
                suffix = _options.PageSuffix;
                break;

            case ContentTypeCategory.Block:
                suffix = _options.BlockSuffix;
                break;

            case ContentTypeCategory.BlockFolder:
            case ContentTypeCategory.Undefined:
            default:
                break;
            }
            if (!string.IsNullOrEmpty(suffix) && !typeName.EndsWith(suffix, StringComparison.InvariantCultureIgnoreCase))
            {
                typeName += suffix;
            }

            // Create name that is valid code
            typeName = _memberNameValidator.CreateIdentifier(typeName);

            return(typeName);
        }