예제 #1
0
        /// <summary>
        /// Creates the corresponding name spaces required for the name provided.
        /// A name space is created/found for each name separated by '/'
        /// </summary>
        /// <param name="enclosingNameSpace">The enclosing name space used to create sub namespaces</param>
        /// <param name="name">The name to consider</param>
        /// <returns></returns>
        private DataDictionary.Types.NameSpace GetNameSpaceBasedOnName(DataDictionary.Types.NameSpace enclosingNameSpace, string name)
        {
            DataDictionary.Types.NameSpace retVal = enclosingNameSpace;

            string[] names = name.Split('/');
            for (int i = 0; i < names.Length; i++)
            {
                DataDictionary.Types.NameSpace current = retVal.findNameSpaceByName(names[i]);
                if (current == null)
                {
                    current      = (DataDictionary.Types.NameSpace)DataDictionary.Generated.acceptor.getFactory().createNameSpace();
                    current.Name = names[i];
                    retVal.appendNameSpaces(current);
                }

                retVal = current;
            }

            return(retVal);
        }
예제 #2
0
        /// <summary>
        ///     Creates a namespace in the dictionary/namespace provided
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected NameSpace CreateNameSpace(ModelElement enclosing, string name)
        {
            NameSpace retVal = (NameSpace)Factory.createNameSpace();

            Dictionary dictionary = enclosing as Dictionary;
            NameSpace  nameSpace  = enclosing as NameSpace;

            if (dictionary != null)
            {
                dictionary.appendNameSpaces(retVal);
            }
            else if (nameSpace != null)
            {
                nameSpace.appendNameSpaces(retVal);
            }
            else
            {
                Assert.Fail();
            }
            retVal.Name = name;

            return(retVal);
        }