Exemplo n.º 1
0
        private object HandleConceptOrExpressionSlotInAttributeValue(
            TemplateInformationSlot infoSlot,
            ConceptReference attrName,
            OneOf <ConceptReplacementSlot, ExpressionReplacementSlot> valueSlot,
            IDictionary <string, TemplateData.Item> itemData,
            string lang
            )
        {
            var(attrTitle, attrDesc) = GetConceptOrSlotTitleAndDesc(infoSlot, attrName, itemData, lang);
            var result = new Dictionary <string, object>
            {
                ["attribute"] = attrName.SctId
            };

            result["title"] = attrTitle ?? throw new Exception($"No title specified for {attrName.SctId}");
            if (attrDesc != null)
            {
                result["description"] = attrDesc;
            }
            result["cardinality"] = new
            {
                min = infoSlot?.Cardinality?.MinCardinality ?? 1,
                max = infoSlot?.Cardinality?.MaxCardinality
            };
            result["value"] = GetConceptSlotJson(valueSlot.Handle(c => c.ExpressionConstraint, e => e.ExpressionConstraint));
            return(result);
        }