public override EntityTemplate VisitRegularField(EntityTemplateParser.RegularFieldContext context) { //we only care about entity template child objects, since they define entity hierarchy. if (context.value().@object() == null) { throw new InvalidDataException( $"Expected from the field '{context.key.Text.Trim(1,1)}' to be an object but it wasn't"); } var childParserVisitor = new EntityTemplateParserVisitor(); var childEntityTemplate = childParserVisitor.Visit(context.value().@object()); var childParserValidator = new EntityTemplateValidatorVisitor(); childParserValidator.Visit(context.value().@object()); if (!childParserValidator.HasIdentifierField) { childEntityTemplate.Id = context.key.Text.Trim(1, 1); } try { DefaultResult.Children.Add(context.key.Text.Trim(1, 1), childEntityTemplate); } catch (ArgumentException e) { throw new InvalidDataException( $"Found duplicate child entity template field. ('{context.key.Text.Trim(1, 1)}'). Did you execute template validation visitor?", e); } return(DefaultResult); }
public override bool VisitRegularField(EntityTemplateParser.RegularFieldContext context) { _doubleFieldCount.AddOrSet($"{string.Join(".",_embeddedObjectContext)}.{context.key.Text.Trim(1,1)}", existing => ++ existing); if (context.value().@object() == null && _embeddedObjectContext.Count == 1) { _nonObjectFieldKeys.Add(context.key.Text.Trim(1, 1)); } return(base.VisitRegularField(context)); }