public static void GenerateChildren(IConfiguration config, IModelSystemStructure element) { if (element == null) { return; } if (element.Type == null) { return; } foreach (var field in element.Type.GetFields()) { IModelSystemStructure child = null; if ((child = GenerateChildren(element, field.FieldType, field.GetCustomAttributes(true), config)) != null) { // set the name child.ParentFieldName = field.Name; child.Name = CreateModuleName(field.Name); if (element.IsCollection) { child.ParentFieldType = field.FieldType.GetGenericArguments()[0]; } else { child.ParentFieldType = field.FieldType; } element.Add(child); } } foreach (var property in element.Type.GetProperties()) { IModelSystemStructure child = null; if ((child = GenerateChildren(element, property.PropertyType, property.GetCustomAttributes(true), config)) != null) { child.ParentFieldName = property.Name; child.Name = CreateModuleName(property.Name); child.ParentFieldType = property.PropertyType; element.Add(child); } } if (element.Children != null & !element.IsCollection) { SortChildren(element.Children); } }
public static void GenerateChildren(IConfiguration config, IModelSystemStructure element) { if(element == null) return; if(element.Type == null) return; foreach(var field in element.Type.GetFields()) { IModelSystemStructure child = null; if((child = GenerateChildren(element, field.FieldType, field.GetCustomAttributes(true), config)) != null) { // set the name child.ParentFieldName = field.Name; child.Name = CreateModuleName(field.Name); if(element.IsCollection) { child.ParentFieldType = field.FieldType.GetGenericArguments()[0]; } else { child.ParentFieldType = field.FieldType; } element.Add(child); } } foreach(var property in element.Type.GetProperties()) { IModelSystemStructure child = null; if((child = GenerateChildren(element, property.PropertyType, property.GetCustomAttributes(true), config)) != null) { child.ParentFieldName = property.Name; child.Name = CreateModuleName(property.Name); child.ParentFieldType = property.PropertyType; element.Add(child); } } if(element.Children != null & !element.IsCollection) { SortChildren(element.Children); } }