private PropertyType MapPropertyType(IContentTypeComposition contentType, PropertyTypeCommonDto dto, IDictionary <string, PropertyType> builtinProperties)
        {
            var groupId = dto.PropertyTypeGroupId;

            var readonlyStorageType = builtinProperties.TryGetValue(dto.Alias, out var propertyType);
            var storageType         = readonlyStorageType ? propertyType.ValueStorageType : Enum <ValueStorageType> .Parse(dto.DataTypeDto.DbType);

            if (contentType is MemberType memberType)
            {
                var access = new MemberTypePropertyProfileAccess(dto.ViewOnProfile, dto.CanEdit, dto.IsSensitive);
                memberType.MemberTypePropertyTypes[dto.Alias] = access;
            }

            return(new PropertyType(dto.DataTypeDto.EditorAlias, storageType, readonlyStorageType, dto.Alias)
            {
                Description = dto.Description,
                DataTypeId = dto.DataTypeId,
                DataTypeKey = dto.DataTypeDto.NodeDto.UniqueId,
                Id = dto.Id,
                Key = dto.UniqueId,
                Mandatory = dto.Mandatory,
                Name = dto.Name,
                PropertyGroupId = groupId.HasValue ? new Lazy <int>(() => groupId.Value) : null,
                SortOrder = dto.SortOrder,
                ValidationRegExp = dto.ValidationRegExp,
                Variations = (ContentVariation)dto.Variations
            });
        }
Example #2
0
        private PropertyType MapPropertyType(IContentTypeComposition contentType, PropertyTypeCommonDto dto, IDictionary <string, PropertyType> builtinProperties)
        {
            var groupId = dto.PropertyTypeGroupId;

            var readonlyStorageType = builtinProperties.TryGetValue(dto.Alias, out var propertyType);
            var storageType         = readonlyStorageType ? propertyType.ValueStorageType : Enum <ValueStorageType> .Parse(dto.DataTypeDto.DbType);

            if (contentType is IMemberType memberType)
            {
                memberType.SetIsSensitiveProperty(dto.Alias, dto.IsSensitive);
                memberType.SetMemberCanEditProperty(dto.Alias, dto.CanEdit);
                memberType.SetMemberCanViewProperty(dto.Alias, dto.ViewOnProfile);
            }

            return(new PropertyType(_shortStringHelper, dto.DataTypeDto.EditorAlias, storageType, readonlyStorageType, dto.Alias)
            {
                Description = dto.Description,
                DataTypeId = dto.DataTypeId,
                DataTypeKey = dto.DataTypeDto.NodeDto.UniqueId,
                Id = dto.Id,
                Key = dto.UniqueId,
                Mandatory = dto.Mandatory,
                MandatoryMessage = dto.MandatoryMessage,
                Name = dto.Name,
                PropertyGroupId = groupId.HasValue ? new Lazy <int>(() => groupId.Value) : null,
                SortOrder = dto.SortOrder,
                ValidationRegExp = dto.ValidationRegExp,
                ValidationRegExpMessage = dto.ValidationRegExpMessage,
                Variations = (ContentVariation)dto.Variations,
                LabelOnTop = dto.LabelOnTop
            });
        }