Example #1
0
        public override HashSet <ContentProperty> GetValue(TEntity source)
        {
            //check all schema definitions for the TPE and add any that don't exist in the TPE's attributes.
            source.SetupFromSchema();

            //now we need to remove any properties that don't exist anymore, excluding the 'special' internal fields
            IEnumerable <string> allAliases = source.EntitySchema.AttributeDefinitions.Select(a => a.Alias)
                                              //.Concat(FixedAttributeDefinitionAliases.AllAliases)
                                              .ToArray();

            // check the aliases of inherited properties as we don't want to remove those
            var compositeSchema = source.EntitySchema as CompositeEntitySchema;

            if (compositeSchema != null)
            {
                allAliases = allAliases.Concat(compositeSchema.InheritedAttributeDefinitions.Select(x => x.Alias)).ToArray();
            }

            var toRemove = source.Attributes.Where(x => !allAliases.Contains(x.AttributeDefinition.Alias))
                           .Select(x => x.Id)
                           .ToArray();

            source.Attributes.RemoveAll(x => toRemove.Contains(x.Id));

            //we don't want to map the 'special' properties
            return(CurrentEngine.Map <IEnumerable <TypedAttribute>, HashSet <ContentProperty> >(source.Attributes));
        }
Example #2
0
        public override AttributeType GetValue(DocumentTypeProperty source)
        {
            // Commented this out, as there was a problem with the AttributeType being updated with the merged config,
            // then the content was saved forcing the AttributeType to resave, overwriting the AttributeTypes default config.
            // As far as I can tell, I can't see a situation where converting a DocTypeProperty to an AttributeType would require
            // it to be mapped, so instead I now just load straight from DB
            // MB

            if (!source.DataTypeId.IsNullValueOrEmpty())
            {
                using (var uow = ResolverContext.Hive.OpenReader <IContentStore>())
                {
                    return(uow.Repositories.Schemas.Get <AttributeType>(source.DataTypeId));
                }
            }

            return(CurrentEngine.Map <DataType, AttributeType>(source.DataType));
        }