public static ModelTypeMetaCategory CreateFrom(TemplateSection section) { var m = new ModelTypeMetaCategory { Identifier = section.SectionId, Fields = null }; if (section.SectionLabels != null && section.SectionLabels.Any()) { m.Labels = section.SectionLabels; } var labels = m.Labels ?? new Dictionary <string, string>(); m.Label = labels.ContainsKey(WebHelper.DefaultLanguage) ? labels[WebHelper.DefaultLanguage] : m.Identifier; var templateFields = section.Fields ?? new List <TemplateField>(); foreach (var templateField in templateFields) { var categoryField = ModelTypeField.CreateFrom(templateField); if (categoryField != null) { m.Fields = m.Fields ?? new List <ModelTypeField>(); m.Fields.Add(categoryField); } } return(m); }
public static ModelTypeMetaCategory CreateFrom(JProperty property) { var m = new ModelTypeMetaCategory { Identifier = property.Name, Fields = null }; var fields = JsonHelper.FindToken(property, ModelData.MetaCategoryFieldsKey); if (fields != null) { foreach (var field in fields.Children()) { var categoryField = ModelTypeField.CreateFrom(field); if (categoryField != null) { m.Fields = m.Fields ?? new List <ModelTypeField>(); m.Fields.Add(categoryField); } } } return(m); }
public static ModelType CreateFrom(Template template) { var t = new ModelType { Name = string.Format(ModelData.TemplateBaseSubNamePattern, template.FormId), SuperName = ModelData.TemplateBaseTypeName, OwnMetaCategories = null }; var sections = template.Sections ?? new List <TemplateSection>(); foreach (var section in sections) { t.OwnMetaCategories = t.OwnMetaCategories ?? new List <ModelTypeMetaCategory>(); var category = ModelTypeMetaCategory.CreateFrom(section); t.OwnMetaCategories.Add(category); } return(t); }
public static ModelType CreateFrom(JProperty typeProperty) { var t = new ModelType { Name = typeProperty.Name, SuperName = JsonHelper.FindTokenValue <string>(typeProperty, ModelData.TypesSuperKey, true), OwnMetaCategories = null }; var categories = JsonHelper.FindToken(typeProperty.Value, ModelData.TypesMetaKey, true); if (categories != null) { foreach (JProperty categoryProperty in categories.Children()) { t.OwnMetaCategories = t.OwnMetaCategories ?? new List <ModelTypeMetaCategory>(); var category = ModelTypeMetaCategory.CreateFrom(categoryProperty); t.OwnMetaCategories.Add(category); } } return(t); }