Ejemplo n.º 1
0
        public ActionResult TypeScriptSchema(int content_item_id, bool isLive = false)
        {
            Content rootContent = _contentDefinitionService.GetDefinitionById(content_item_id, isLive);

            ProductSchema productSchema = _editorSchemaService.GetProductSchema(rootContent);

            Dictionary <int, ContentSchema> mergedSchema = _editorSchemaService.GetMergedContentSchemas(productSchema);

            string editorSchemaJson = JsonConvert.SerializeObject(productSchema, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Include,
                Converters        = { new StringEnumConverter() }
            });

            string mergedSchemaJson = JsonConvert.SerializeObject(mergedSchema, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Include,
                Converters        = { new StringEnumConverter() }
            });

            return(View(new ProductEditorSchemaModel
            {
                EditorSchema = editorSchemaJson,
                MergedSchema = mergedSchemaJson,
            }));
        }
Ejemplo n.º 2
0
        protected ProductSchema LoadProductSchemaFromFile(string filename)
        {
            int intBuffer;
            var jObject = LoadJObjectFromFile(filename);
            var schema  = new ProductSchema();

            schema.Id      = jObject["ProductId"]?.Value <string>();
            schema.Type    = jObject["Type"]?.Value <string>();
            schema.Title   = jObject["Title"]?.Value <string>();
            schema.Version = jObject["Version"]?.Value <string>();
            if (Int32.TryParse(jObject["BaseSiteMB"]?.Value <string>(), out intBuffer))
            {
                schema.BaseSiteMB = intBuffer;
            }
            if (Int32.TryParse(jObject["IncClientMB"]?.Value <string>(), out intBuffer))
            {
                schema.IncClientMB = intBuffer;
            }
            schema.Features.AddRange(GetFeaturesFromJObject(jObject));
            schema.SiteTemplates.AddRange(GetSiteTemplatesFromJObjectAsync(jObject));
            return(schema);
        }
        public ContentResult GetEditorSchema(int productDefinitionId, bool isLive = false)
        {
            Content rootContent = _contentDefinitionService.GetDefinitionById(productDefinitionId, isLive);

            ProductSchema productSchema = _editorSchemaService.GetProductSchema(rootContent);

            Dictionary <int, ContentSchema> mergedSchemas = _editorSchemaService.GetMergedContentSchemas(productSchema);

            var schemaModel = new
            {
                EditorSchema  = productSchema,
                MergedSchemas = mergedSchemas,
            };

            string schemaJson = JsonConvert.SerializeObject(schemaModel, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Include,
                Converters        = { new StringEnumConverter() }
            });

            return(Content(schemaJson, "application/json"));
        }