示例#1
0
        /// <summary>
        /// Генерация схемы для редактирования контентов
        /// </summary>
        /// <exception cref="NotSupportedException" />
        /// <exception cref="InvalidOperationException" />
        public ProductSchema GetProductSchema(Content content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            _contentService.LoadStructureCache();
            _fieldService.LoadStructureCache();

            VirtualFieldContext virtualFieldContext = _virtualFieldContextService.GetVirtualFieldContext(content);

            var context = new SchemaContext
            {
                Dictionaries  = content.Fields.OfType <Dictionaries>().SingleOrDefault(),
                IgnoredFields = virtualFieldContext.IgnoredFields,
            };

            ContentSchema contentSchema = GetContentSchema(content, context, "");

            ProductSchema productSchema = GetProductSchema(contentSchema, context);

            return(productSchema);
        }
示例#2
0
        /// <summary>
        /// Генерация словаря с объединенными схемами для каждого <see cref="ContentSchema.ContentId"/> из продукта
        /// </summary>
        public Dictionary <int, ContentSchema> GetMergedContentSchemas(ProductSchema productSchema)
        {
            var schemasByContentId = new Dictionary <int, ContentSchema>();

            if (productSchema.Content is ContentSchema)
            {
                CreateEmptyContentSchemas((ContentSchema)productSchema.Content, schemasByContentId);
            }
            foreach (ContentSchema definitionSchema in productSchema.Definitions.Values)
            {
                CreateEmptyContentSchemas(definitionSchema, schemasByContentId);
            }

            if (productSchema.Content is ContentSchema)
            {
                FillMergedContentSchemas((ContentSchema)productSchema.Content, schemasByContentId);
            }
            foreach (ContentSchema definitionSchema in productSchema.Definitions.Values)
            {
                FillMergedContentSchemas(definitionSchema, schemasByContentId);
            }

            return(schemasByContentId);
        }