Esempio n. 1
0
        public NestedEntities BuildNestedEntities(NestedLines nestedLines, String entityName, NestedEntity parent, int level = 1)
        {
            var nestedEntities = new NestedEntities();

            foreach (var line in nestedLines.Lines)
            {
                var idField = line.GetId(entityName, level);

                if (idField == null || !_entitiesList.ContainsKey(entityName))
                {
                    continue;
                }

                var entityType = _entitiesList[entityName];

                NestedEntity nestedEntity = new NestedEntity(idField.Value.ToString(), entityName, entityType);

                nestedEntity.NestedFields.AddRange(line.Fields.Where(x => x.Name.Length == level + 1).ToList());

                if (parent != null)
                {
                    parent.AddChild(nestedEntity.EntityName, nestedEntity);
                }

                var fieldsByEntity = line.GroupFieldsByEntity(level + 1);

                foreach (var item in fieldsByEntity)
                {
                    if (!_entitiesList.ContainsKey(item.Key))
                    {
                        continue;
                    }

                    BuildNestedEntities(new NestedLines(new List <NestedLine> {
                        new NestedLine(item.ToList())
                    }), item.Key, nestedEntity, level + 1);
                }

                nestedEntities.Add(nestedEntity);
            }

            return(nestedEntities);
        }
Esempio n. 2
0
 internal void AddChild(string entityName, NestedEntity nestedEntity)
 {
     Childs.Add(entityName, nestedEntity);
 }
Esempio n. 3
0
        public NestedEntities Add(NestedEntity entity)
        {
            _entities.Add(entity);

            return(this);
        }