///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="collectionType">The type of collection to get.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode collectionType, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject collectionContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                collectionContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                collectionContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            else if (SpecCurrentItem != null)
            {
                collectionContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindAllMethod && ModelProperty != null)
            {
                IEnterpriseEnumerable collection = collectionType.GetCollection(solutionContext, templateContext, collectionContext);
                if (collection != null)
                {
                    return(collection.FindItems(ModelProperty.ModelPropertyName, Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType)));
                }
            }
            else if (MethodName == LanguageTerms.GetEntityAndBasesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> entities = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        entities.Add(currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(entities);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.GetBaseAndEntitiesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> items = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        items.Insert(0, currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.ExtendingEntitiesCollection)
            {
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).ExtendingEntites);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Property loopItem in loopEntity.PropertyList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (PropertyReference loopItem in loopEntity.PropertyReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (EntityReference loopItem in loopEntity.EntityReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Collection loopItem in loopEntity.CollectionList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Relationship loopItem in loopEntity.RelationshipList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Index loopItem in loopEntity.IndexList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Method loopItem in loopEntity.MethodList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.PathRelationships)
            {
                if (collectionType.ModelContextName == "Relationship" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).PathRelationships);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the model context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public IDomainEnterpriseObject GetModelContext(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, out bool isValidContext)
        {
            IDomainEnterpriseObject nodeContext      = modelContext;
            IDomainEnterpriseObject currentContext   = modelContext;
            ModelContextNode        leafModelContext = ModelContext;

            isValidContext = false;
            if (ThisContext != null)
            {
                templateContext.PopCount = templateContext.ModelContextStack.Count - 1;
            }
            else if (PopContext != null)
            {
                // go through pop context nodes directly here
                ModelContextNode contextNode = this;
                while (contextNode != null)
                {
                    if (contextNode.PopContext != null)
                    {
                        leafModelContext = contextNode.ModelContext;
                        templateContext.PopCount++;
                    }
                    contextNode = contextNode.ModelContext;
                }
            }
            if (templateContext.PopCount > 0)
            {
                // pop context executes first
                nodeContext = templateContext.GetModelContext(templateContext.PopCount);
                templateContext.PopCount = 0;
            }
            if (leafModelContext != null)
            {
                // model context nodes execute next (then, nodes are evaluated)
                nodeContext = leafModelContext.GetModelContext(solutionContext, templateContext, nodeContext, out isValidContext);
            }
            if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.AuditProperty))
            {
                nodeContext = AuditProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Collection))
            {
                nodeContext = Collection.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Entity))
            {
                nodeContext = Entity.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.EntityReference))
            {
                nodeContext = EntityReference.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Enumeration))
            {
                nodeContext = Enumeration.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Feature))
            {
                nodeContext = Feature.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Index))
            {
                nodeContext = Index.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.IndexProperty))
            {
                nodeContext = IndexProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Method))
            {
                nodeContext = Method.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.MethodRelationship))
            {
                nodeContext = MethodRelationship.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Model))
            {
                nodeContext = Model.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.ModelObject))
            {
                nodeContext = ModelObject.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.ModelProperty))
            {
                nodeContext = ModelProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.ObjectInstance))
            {
                nodeContext = ObjectInstance.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Parameter))
            {
                nodeContext = Parameter.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Project))
            {
                nodeContext = Project.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Property))
            {
                nodeContext = Property.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.PropertyInstance))
            {
                nodeContext = PropertyInstance.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.PropertyReference))
            {
                nodeContext = PropertyReference.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.PropertyRelationship))
            {
                nodeContext = PropertyRelationship.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Relationship))
            {
                nodeContext = Relationship.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.RelationshipProperty))
            {
                nodeContext = RelationshipProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Solution))
            {
                nodeContext = Solution.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Stage))
            {
                nodeContext = Stage.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.StageTransition))
            {
                nodeContext = StageTransition.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.State))
            {
                nodeContext = State.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.StateModel))
            {
                nodeContext = StateModel.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.StateTransition))
            {
                nodeContext = StateTransition.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Step))
            {
                nodeContext = Step.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.StepTransition))
            {
                nodeContext = StepTransition.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Value))
            {
                nodeContext = Value.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.View))
            {
                nodeContext = View.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.ViewProperty))
            {
                nodeContext = ViewProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(ModelContextTypeCode), ModelContextTypeCode.Workflow))
            {
                nodeContext = Workflow.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlColumn))
            {
                nodeContext = SqlColumn.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlDatabase))
            {
                nodeContext = SqlDatabase.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlExtendedProperty))
            {
                nodeContext = SqlExtendedProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlForeignKey))
            {
                nodeContext = SqlForeignKey.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlForeignKeyColumn))
            {
                nodeContext = SqlForeignKeyColumn.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlIndex))
            {
                nodeContext = SqlIndex.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlIndexedColumn))
            {
                nodeContext = SqlIndexedColumn.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlProperty))
            {
                nodeContext = SqlProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlTable))
            {
                nodeContext = SqlTable.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlView))
            {
                nodeContext = SqlView.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.SqlViewProperty))
            {
                nodeContext = SqlViewProperty.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.XmlAttribute))
            {
                nodeContext = XmlAttribute.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.XmlDocument))
            {
                nodeContext = XmlDocument.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            else if (ModelContextName == Enum.GetName(typeof(SpecModelContextTypeCode), SpecModelContextTypeCode.XmlNode))
            {
                nodeContext = XmlNode.GetModelContext(solutionContext, nodeContext, out isValidContext);
            }
            #region protected
            else if (ModelContextName == "ReferencedEntity")
            {
                currentContext = nodeContext;
                nodeContext    = Collection.GetModelContext(solutionContext, currentContext, out isValidContext);
                if (nodeContext is Collection)
                {
                    nodeContext = (nodeContext as Collection).ReferencedEntity;
                }
                else
                {
                    nodeContext = EntityReference.GetModelContext(solutionContext, currentContext, out isValidContext);
                    if (nodeContext is EntityReference)
                    {
                        nodeContext = (nodeContext as EntityReference).ReferencedEntity;
                    }
                    else
                    {
                        nodeContext = Relationship.GetModelContext(solutionContext, currentContext, out isValidContext);
                        if (nodeContext is Relationship)
                        {
                            nodeContext = (nodeContext as Relationship).ReferencedEntity;
                        }
                        else
                        {
                            nodeContext = Parameter.GetModelContext(solutionContext, currentContext, out isValidContext);
                            if (nodeContext is Parameter)
                            {
                                nodeContext = (nodeContext as Parameter).ReferencedEntity;
                            }
                        }
                    }
                }
            }
            else if (ModelContextName == "ReferencedProperty")
            {
                currentContext = nodeContext;
                nodeContext    = RelationshipProperty.GetModelContext(solutionContext, currentContext, out isValidContext);
                if (nodeContext is RelationshipProperty)
                {
                    nodeContext = (nodeContext as RelationshipProperty).ReferencedProperty;
                }
                else
                {
                    nodeContext = PropertyReference.GetModelContext(solutionContext, currentContext, out isValidContext);
                    if (nodeContext is PropertyReference)
                    {
                        nodeContext = (nodeContext as PropertyReference).ReferencedProperty;
                    }
                    else
                    {
                        nodeContext = Parameter.GetModelContext(solutionContext, currentContext, out isValidContext);
                        if (nodeContext is Parameter)
                        {
                            nodeContext = (nodeContext as Parameter).ReferencedPropertyBase as Property;
                        }
                    }
                }
            }
            else if (ModelContextName == "BaseEntity")
            {
                nodeContext = Entity.GetModelContext(solutionContext, nodeContext, out isValidContext);
                if (nodeContext is Entity)
                {
                    nodeContext = (nodeContext as Entity).BaseEntity;
                }
            }
            else if (solutionContext.ModelObjectPropertyNames[ModelContextName] != null)
            {
                nodeContext = ObjectInstance.GetModelContextViaProperty(solutionContext, ModelContextName, nodeContext, out isValidContext);
            }
            #endregion protected
            else if (solutionContext.ModelObjectNames.AllKeys.Contains(ModelContextName) == true)
            {
                return(ObjectInstance.GetModelContext(solutionContext, ModelContextName, nodeContext, out isValidContext));
            }
            if (nodeContext == null && isValidContext == false)
            {
                LogException(solutionContext, templateContext, modelContext, String.Format(DisplayValues.Exception_InvalidModelContext, ModelContextName, modelContext.Name, modelContext.GetType().Name), InterpreterTypeCode.None);
            }
            return(nodeContext);
        }
Ejemplo n.º 3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the model context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="helperModelContext">The associated helper model context node.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IDomainEnterpriseObject GetModelContext(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode helperModelContext, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject parentContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                parentContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                parentContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindMethod)
            {
                IEnterpriseEnumerable collection = helperModelContext.GetCollection(solutionContext, templateContext, parentContext);
                if (collection != null)
                {
                    if (ModelProperty != null)
                    {
                        object paramValue            = Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType);
                        IDomainEnterpriseObject item = collection.FindItem(ModelProperty.ModelPropertyName, paramValue) as IDomainEnterpriseObject;
                        if (item != null)
                        {
                            return(item);
                        }
                        if (modelContext is ObjectInstance)
                        {
                            // get item by specified model property
                            foreach (ObjectInstance instance in collection)
                            {
                                foreach (PropertyInstance property in instance.PropertyInstanceList)
                                {
                                    if (property.ModelPropertyName == ModelProperty.ModelPropertyName && property.PropertyValue == paramValue.ToString())
                                    {
                                        return(instance);
                                    }
                                }
                            }
                        }
                        return(null);
                    }
                    else
                    {
                        string parameterValue = Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                        Guid   parameterID    = Guid.Empty;
                        if (Guid.TryParse(parameterValue, out parameterID))
                        {
                            return(collection.FindItemByID(parameterID) as IDomainEnterpriseObject);
                        }
                        else
                        {
                            LogException(solutionContext, templateContext, modelContext, DisplayValues.Message_InterpreterBadFindParameter, interpreterType);
                        }
                    }
                }
                return(null);
            }
            return(modelContext);
        }
Ejemplo n.º 4
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode collectionType, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject collectionContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                collectionContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (CurrentItem != null)
            {
                collectionContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (SpecCurrentItem != null)
            {
                collectionContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                return(collectionType.GetCollection(solutionContext, templateContext, collectionContext));
            }
            else if (CollectionHelper != null)
            {
                return(CollectionHelper.GetCollection(solutionContext, templateContext, modelContext, collectionType, interpreterType));
            }
            return(null);
        }