public static SemanticRuleViolation AggregateIdentifierMustBeAValueObject(AggregateSyntax aggregate) { return new SemanticRuleViolation( RuleCodes.AggregateIdentifierMustBeAValueObject, String.Format("Identifier for '{0}' must be a value object.", aggregate.Name), aggregate); }
public static SemanticRuleViolation AggregateMustHaveIdentifier(AggregateSyntax aggregate) { return new SemanticRuleViolation( RuleCodes.AggregateMustHaveIdentifier, String.Format("Aggregate '{0}' must have an identifier, either by inheriting from a base aggregate or by specifying an identifier type.", aggregate.Name), aggregate); }
private void Visit(AggregateSyntax aggregate) { if (aggregate.Identifier.HasValue) { var id = aggregate.Identifier.Value; if (id is NamedAggregateIdentifierSyntax) ValidateNamedAggregateIdentifier((NamedAggregateIdentifierSyntax) id, aggregate); if (id is GenericAggregateIdentifierSyntax) ValidateGenericAggregateIdentifier((GenericAggregateIdentifierSyntax) id, aggregate); } else if(!aggregate.Base.HasValue) Fail(SemanticRuleViolation.AggregateMustHaveIdentifier(aggregate)); }
private void ValidateNamedAggregateIdentifier(NamedAggregateIdentifierSyntax id, AggregateSyntax aggregate) { var idSymbol = ResolveAndValidateTypeExists(aggregate, id.Type.Name); if (!idSymbol.HasValue) return; var idType = idSymbol.Value as IType; if (idType == null) { Fail(SemanticRuleViolation.AggregateIdentifierMustBeAValueObject(aggregate)); return; } if (!idType.HasValueSemantics) { Fail(SemanticRuleViolation.AggregateIdentifierMustBeAValueObject(aggregate)); return; } }
private void ValidateGenericAggregateIdentifier(GenericAggregateIdentifierSyntax id, AggregateSyntax aggregate) { throw new System.NotImplementedException(); }