Exemplo n.º 1
0
        // ========================================================================
        /// Parse project name.
        ///
        /// @param projectName The full name of the project.
        /// @return An array of the project name constituents.
        ///
        static string[] SplitPackageName(string projectName)
        {
            // -- Convert file path to namespace format. --
            projectName = projectName.Replace('/', '.');
            // -- Remove all illegal characters. --
            var cleanName = new StringBuilder(64);
            var len       = projectName.Length;

            for (int i = 0; i < len; ++i)
            {
                char c = projectName[i];
                if (cleanName.Length == 0)
                {
                    if (ParsingUtility.IsFirstIdent(c))
                    {
                        cleanName.Append(c);
                    }
                }
                else if (Char.IsWhiteSpace(c) || c == '.' || ParsingUtility.IsIdent(c))
                {
                    cleanName.Append(c);
                }
                else
                {
                    cleanName.Append(' ');
                }
            }
            // -- Split the name into its parts. --
            var splitName = cleanName.ToString().Split(new Char[] { '.' });

            // -- Convert each part to a type format. --
            for (int i = 0; i < splitName.Length; ++i)
            {
                splitName[i] = NameUtility.ToTypeName(splitName[i]);
            }
            return(splitName);
        }