public AbstractionDeclaration Add <SubType, SuperType>(string label = null)
            where SubType : IEntity
            where SuperType : IEntity
        {
            var decl = AbstractionDeclaration.Create <SubType, SuperType>(label);

            abstractions.Add(decl);

            return(decl);
        }
Exemple #2
0
        protected void LogVisitedAbstraction(IContext context, AbstractionDeclaration abstraction)
        {
            Type tcontext = context.GetType();

            if (!visitedContextAbstractions.ContainsKey(tcontext))
            {
                visitedContextAbstractions[tcontext] = new List <AbstractionDeclaration>();
            }

            visitedContextAbstractions[tcontext].Add(abstraction);
        }
Exemple #3
0
        protected void DrillIntoAbstraction(Stack <ContextPath> contextPath, IContext context, Group group, AbstractionDeclaration abstraction)
        {
            LogEntityType(abstraction.SuperType);
            LogRelationship(abstraction.SubType, abstraction.SuperType);
            LogVisitedAbstraction(context, abstraction);

            if (abstraction.SuperType.HasBaseClass <Context>())
            {
                Log?.Invoke("Abstraction: Drilling into " + abstraction.SuperType.Name);
                // Create the context so we can explore its declarations of entities, relationships, abstractions, and IValueEntity types.
                IContext superContext = (IContext)Activator.CreateInstance(abstraction.SuperType);
                MapPotentialLookup(superContext, abstraction.SuperType);
                var rootEntities = superContext.RootEntities;

                if (rootEntities.Count() > 0)
                {
                    Group group2 = group;

                    if (!abstraction.ShouldCoalesceAbstraction)
                    {
                        group2 = CreateGroup(abstraction.SuperType, RelationshipDeclaration.NullRelationship, contextPath, abstraction.Label);
                        groups.Add(group2);
                    }

                    foreach (var root in rootEntities)
                    {
                        contextPath.Push(new ContextPath(ContextPath.ContextPathType.Abstraction, abstraction.SuperType));
                        CreateFields(contextPath, superContext, group2);
                        PopulateGroupFields(contextPath, superContext, group2, root);
                        contextPath.Pop();
                    }
                }
            }

            // TODO: What if the abstraction is a plain-old entity?
            // Entities never have content?  Anything that has content would be in a context!
        }