コード例 #1
0
ファイル: InstanceDesign.cs プロジェクト: mpostol/ASMD
        /// <summary>
        /// Processes the node.
        /// </summary>
        /// <param name="space">The address space.</param>
        /// <param name="nodeContext">The parent.</param>
        /// <param name="modelParent">The model parent.</param>
        /// <param name="isInstanceDeclaration">if set to <c>true</c> it is instance declaration.</param>
        void IInstanceNode.CompileNode(IAddressSpaceCreator space, IInstanceNodeContext nodeContext, bool isInstanceDeclaration)
        {
            IInstanceNodesCollection children = AddChildren(space, nodeContext.NodeID, nodeContext.AddressSpaceIndex, isInstanceDeclaration);

            InstanceDeclarations(children, nodeContext);
            children.RegisterChildrenInAddressSpace();
            foreach (Reference item in this.References)
            {
                space.AddReference(nodeContext.AddressSpaceIndex, item.Wrapper.ReferenceType.XmlQualifiedName, item.Wrapper.IsInverse, item.Wrapper.TargetId.XmlQualifiedName);
            }
            space.AddReference(nodeContext.AddressSpaceIndex, BuildInXmlQualifiedNames.HasTypeDefinition, false, nodeContext.TypeDefinition);
            nodeContext.AddModelingRule();
        }
コード例 #2
0
        /// <summary>
        /// Adds the <see cref="IInstanceNode" /> to the collection of a type children with goal to build inheritance chain and override the attributes of the base type by the derived type.
        /// </summary>
        /// <param name="childItem">The child item of the <paramref name="modelParentNode" />.</param>
        /// <param name="modelParentNode">The model parent node - the node, which type is processed and <paramref name="childItem" /> added.</param>
        /// <param name="typeParentID">The parent identifier of the type provisioning instance declarations - prefix to the relative reference path.</param>
        void IInstanceNodesCollection.Add(IInstanceNode childItem, IInstanceNodeContext modelParentNode, XmlQualifiedName typeParentID)
        {
            XmlQualifiedName _itemNodeID       = InstanceIdentifier.AddSuffix(modelParentNode.NodeID, childItem.SymbolicName.Name);
            string           _stringItemNodeID = InstanceIdentifier.NodeId(_itemNodeID);

            if (this.m_dictionary.ContainsKey(_stringItemNodeID))
            {
                this.m_dictionary[_stringItemNodeID].AddInstanceDeclarationOf(childItem, typeParentID);
            }
            else
            {
                this.Add(_stringItemNodeID, childItem, _itemNodeID, modelParentNode.AddressSpaceIndex, true);
            }
        }
コード例 #3
0
ファイル: InstanceDesign.cs プロジェクト: mpostol/ASMD
        /// <summary>
        /// Adds to address space.
        /// </summary>
        /// <param name="children">The children.</param>
        /// <returns></returns>
        protected void InstanceDeclarations(IInstanceNodesCollection children, IInstanceNodeContext thisInstance)
        {
            //Methods do not have equivalent of type definition reference.
            if (this.NodeClass == NodeClassesEnum.Method)
            {
                return;
            }
            ITypeDesign type = SolutionTreeNode.SolutionRoot.FindType(thisInstance.TypeDefinition);

            if (type == null)
            {
                thisInstance.Assert(false, "Cannot find TypeDefinition for the instance.");
                return;
            }
            type.InstanceDeclarations(children, thisInstance);
        }
コード例 #4
0
ファイル: TypeDesign.cs プロジェクト: lwh125630hui/ASMD
 /// <summary>
 /// Instances the declarations.
 /// </summary>
 /// <param name="childrenCollection">The children collection.</param>
 /// <param name="parent">The parent.</param>
 void ITypeDesign.InstanceDeclarations(IInstanceNodesCollection childrenCollection, IInstanceNodeContext parent)
 {
     m_InheritanceDepth++;
     try
     {
         if (m_InheritanceDepth > m_MaxInheritanceDepth)
         {
             parent.Assert(false, String.Format("The depth of instance declaration is greater than the maximum {0}", m_MaxInheritanceDepth));
             return;
         }
         foreach (IInstanceNode _childItem in this.Children)
         {
             if (!_childItem.IsMandatory)
             {
                 continue;
             }
             childrenCollection.Add(_childItem, parent, parent.NodeID);
         }
         foreach (Reference item in References)
         {
             parent.AddReference(item, this, parent.NodeID);
         }
         XmlQualifiedName myType = this.Wrapper.BaseType.ValueOrDefault;
         ITypeDesign      type   = SolutionTreeNode.SolutionRoot.FindType(myType);
         if (this.Wrapper.IsItRootType)
         {
             return;
         }
         if (type == null)
         {
             parent.Assert(false, "Broken inheritance chain of the base type for this node.");
             return;
         }
         type.InstanceDeclarations(childrenCollection, parent);
     }
     finally
     {
         m_InheritanceDepth--;
     }
 }