コード例 #1
0
        public void FindTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.BaseDirectory).Returns(@"C:\");
            ProjectTreeNode  _emptyModel = ProjectTreeNode.CreateNewModel(_directory.Object);
            XmlQualifiedName _toFind     = new XmlQualifiedName("Name", "Namespace");
            ITypeDesign      _findReturn = _emptyModel.Find(_toFind);

            Assert.IsNull(_findReturn);
        }
コード例 #2
0
 /// <summary>
 /// Finds the type starting form <see cref="Root.SolutionRoot"/> and if not succeeded tries <see cref="Root.LibraryRoot"/>.
 /// </summary>
 /// <param name="myType">My type.</param>
 /// <returns></returns>
 internal ITypeDesign FindType(XmlQualifiedName myType)
 {
     foreach (ProjectTreeNode node in this)
     {
         ITypeDesign ret = node.Find(myType);
         if (ret != null)
         {
             return(ret);
         }
     }
     return(LibraryRoot.FindType(myType));
 }
コード例 #3
0
ファイル: LibraryTreeNode.cs プロジェクト: mpostol/ASMD
 internal ITypeDesign FindType(XmlQualifiedName myType)
 {
     foreach (ModelDesign node in this)
     {
         ITypeDesign ret = node.FindType(myType);
         if (ret != null)
         {
             return(ret);
         }
     }
     return(null);
 }
コード例 #4
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);
        }
コード例 #5
0
ファイル: ModelDesign.cs プロジェクト: mpostol/ASMD
        internal ITypeDesign FindType(XmlQualifiedName myType)
        {
            ITypeDesign ret = null;

            foreach (IBaseModel item in this)
            {
                INodeDesign node = item as INodeDesign;
                if ((node != null) && (node.SymbolicName == myType))
                {
                    ret = node as ITypeDesign;
                    if (ret != null)
                    {
                        break;
                    }
                }
            }
            return(ret);
        }
コード例 #6
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--;
     }
 }
コード例 #7
0
        public void FindTest()
        {
            Mock <IProjectConfigurationManagement> _projectConfigurationMock = new Mock <IProjectConfigurationManagement>();
            Mock <OPCFModelDesign> _OPCFModelDesignMock = new Mock <OPCFModelDesign>();

            _projectConfigurationMock.SetupGet <OPCFModelDesign>(x => x.ModelDesign).Returns(_OPCFModelDesignMock.Object);
            _projectConfigurationMock.SetupGet <string>(x => x.Name).Returns("EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327");
            Mock <BaseTreeNode> _parentMock = new Mock <BaseTreeNode>("ParentBaseNode");

            _parentMock.SetupGet <string[]>(x => x.AvailiableNamespaces).Returns(new List <string>()
            {
                "ns1", "ns2"
            }.ToArray());
            ProjectTreeNode _newItem = new ProjectTreeNode(_projectConfigurationMock.Object)
            {
                Parent = _parentMock.Object
            };

            XmlQualifiedName _toFind     = new XmlQualifiedName("Name", "Namespace");
            ITypeDesign      _findReturn = _newItem.Find(_toFind);

            Assert.IsNull(_findReturn);
        }