コード例 #1
0
        /// <summary>
        /// Provides the type which corresponds to the given name
        /// </summary>
        /// <param name="name">the type name to find</param>
        /// <param name="findInEnclosingNameSpaces">indicates that the search must be performed in the enclosing namespaces</param>
        /// <returns></returns>
        private Type innerFindTypeByName(string name, bool findInEnclosingNameSpaces)
        {
            Type retVal = null;

            string[] names = name.Split('.');
            if (names.Length == 1)
            {
                retVal = (Type)Utils.INamableUtils.findByName(name, Types);
            }
            else
            {
                NameSpace nameSpace = (NameSpace)Utils.INamableUtils.findByName(names[0], SubNameSpaces);
                if (nameSpace != null)
                {
                    retVal = nameSpace.innerFindTypeByName(name.Substring(nameSpace.Name.Length + 1), false);
                }
            }

            if (retVal == null && findInEnclosingNameSpaces && EnclosingNameSpace != null)
            {
                retVal = EnclosingNameSpace.innerFindTypeByName(name, true);
            }

            return(retVal);
        }
コード例 #2
0
ファイル: NameSpace.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <summary>
        ///     Provides the type which corresponds to the given name
        /// </summary>
        /// <param name="name">the type name to find</param>
        /// <param name="findInEnclosingNameSpaces">indicates that the search must be performed in the enclosing namespaces</param>
        /// <returns></returns>
        private Type innerFindTypeByName(string name, bool findInEnclosingNameSpaces)
        {
            Type retVal = null;

            string[] names = name.Split('.');
            if (names.Length == 1)
            {
                retVal = (Type)NamableUtils.FindByName(name, Types);
            }
            else
            {
                NameSpace nameSpace = (NameSpace)NamableUtils.FindByName(names[0], NameSpaces);
                if (nameSpace != null)
                {
                    retVal = nameSpace.innerFindTypeByName(name.Substring(nameSpace.Name.Length + 1), false);
                }
            }

            if (retVal == null && findInEnclosingNameSpaces && EnclosingNameSpace != null)
            {
                retVal = EnclosingNameSpace.innerFindTypeByName(name, true);
            }

            //HacK: get the unified structure to take care of Updates
            Structure structure = retVal as Structure;

            if (structure != null)
            {
                retVal = structure.UnifiedStructure;
            }

            //HacK: get the unified state machine to take care of Updates
            StateMachine stateMachine = retVal as StateMachine;

            if (stateMachine != null)
            {
                retVal = stateMachine.UnifiedStateMachine;
            }

            return(retVal);
        }