protected Group CreateGroup(Type t, RelationshipDeclaration relationship, Stack <ContextPath> contextPath, string label) { Log?.Invoke(CRLF + "Creating group: " + t.Name + " relationship: " + relationship.RelationshipType.Name); Group group = new Group(label ?? relationship.Label ?? t.Name, t, contextPath, relationship); return(group); }
protected Group CreateGroup(EntityDeclaration decl, RelationshipDeclaration relationship, Stack <ContextPath> contextPath) { Log?.Invoke(CRLF + "Creating group: " + decl.EntityType.Name + " relationship: " + relationship.RelationshipType.Name); Group group = new Group(decl.Label ?? relationship.Label, decl.EntityType, contextPath, relationship); return(group); }
public Group(string name, Type contextType, Stack <ContextPath> contextPath, RelationshipDeclaration relationship) { Name = name; Relationship = relationship; ContextType = contextType; this.contextPath = contextPath.Reverse().ToList(); }
protected Group CreateGroup(IContext context, RelationshipDeclaration relationship, Stack <ContextPath> contextPath) { Type t = context.GetType(); Log?.Invoke(CRLF + "Creating group: " + t.Name + " relationship: " + relationship.RelationshipType.Name); Group group = new Group(relationship.Label ?? context.Label ?? t.Name, t, contextPath, relationship); return(group); }
public RelationshipDeclaration Add <R, T, S>(string label = null) where R : IRelationship where T : IEntity where S : IEntity { var rel = RelationshipDeclaration.Create <R, T, S>(label); relationships.Add(rel); return(rel); }
protected Group GenerateMasterGroups(Stack <ContextPath> contextPath, List <Group> groups, Group group, IContext context, RelationshipDeclaration relationship) { if (contextPath.Any(c => c.Type == context.GetType())) { throw new ContextException("Context " + context.GetType().Name + " is recursive."); } Log?.Invoke("Top level root entity: " + context.GetType().Name); LogEntityType(context.GetType()); //Group group = CreateGroup(context, relationship, contextPath); //groups.Add(group); if (relationship.RelationshipType == typeof(NullRelationship)) { contextPath.Push(new ContextPath(ContextPath.ContextPathType.Root, context.GetType())); } else { contextPath.Push(new ContextPath(ContextPath.ContextPathType.Relationship, context.GetType())); } var rootEntities = context.RootEntities; CreateFields(contextPath, context, group); foreach (var root in rootEntities) { DrillIntoAbstraction(contextPath, context, group, root); } GenerateRelationalGroups(contextPath, groups, group, context); // Get all abstractions defined by self-context. // This handles abstractions declared on this context by this context. // We skip abstractions we've already drilled into. // TODO: This seems kludgy but if we omit this, the unit tests on self-declared abstractions fails. // However, we can't qualify abstractions by this context type because then disassociated context don't // get parsed, which causes the DisassociatedAbtractionTest to fail. var abstractions = context.GetAbstractions(); Type tcontext = context.GetType(); foreach (var abstraction in abstractions) { // We only drill into abstractions that we haven't visited for this context. // See unit tests: // ContextWithAbstractionAndRelationTest // SubcontextWithSelfAbstractionTest // ContextWithAbstractionAndRelationshipTest if (!visitedContextAbstractions.ContainsKey(tcontext) || !visitedContextAbstractions[tcontext].Contains(abstraction)) { DrillIntoAbstraction(contextPath, context, group, abstraction); } } contextPath.Pop(); return(group); }