Example #1
0
        /// <summary>
        /// This method gets the Generic Event Description.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns></returns>
        private static string GetGenericEventDescritpion(string eventName)
        {
            // initial value
            string description = "";

            // Create  string builder
            StringBuilder sb = new StringBuilder("");

            // locals
            bool   isVerb    = false;
            string firstWord = "";
            string lastWord  = "";

            // Get the words
            List <Word> words = CSharpCodeParser.ParseWordsByCapitalLetters(eventName);

            // if there are one or more words
            if ((words != null) && (words.Count > 0))
            {
                // we have to test if the first word is a verb
                isVerb    = false;
                firstWord = words[0].Text;
                lastWord  = words[words.Count - 1].Text;

                // we have to determine if the first word is a verb
                isVerb = IsVerb(firstWord);

                // if the first word is a verb
                if (isVerb)
                {
                    // remove the first word
                    words.RemoveAt(0);
                }

                // now iterate the words
                foreach (Word word in words)
                {
                    // append the text of this word
                    sb.Append(" " + word.Text);
                }

                // Trim
                description = sb.ToString().Trim();
            }

            // return value
            return(description);
        }
Example #2
0
        /// <summary>
        /// This method returns the method description based upon the method name.
        /// </summary>
        /// <param name="methodName"></param>
        /// <returns></returns>
        public static string GetMethodDescription(string methodName, string returnType)
        {
            // initail value
            string description = "";

            // first we have to test if this methodName is handled
            description = GetPreProcessedDescription(methodName);

            // if the string still does not exist
            if (String.IsNullOrEmpty(description))
            {
                // Create  string builder
                StringBuilder sb = new StringBuilder("");

                // Get the words
                List <Word> words = CSharpCodeParser.ParseWordsByCapitalLetters(methodName);

                // if the return Type exists
                bool hasReturnType = (!String.IsNullOrEmpty(returnType));

                // if there is a return type and it is not void
                if ((hasReturnType) && (returnType != "void"))
                {
                    // if this is a list or a collection
                    if ((returnType.Contains("List")) || (returnType.Contains("Collection")))
                    {
                        // add the word returns
                        sb.Append(" returns a list of");
                    }
                    else
                    {
                        // add the word returns
                        sb.Append(" returns the ");
                    }

                    // if there are one or more words
                    if ((words != null) && (words.Count > 0))
                    {
                        // we have to test if the first word is a verb
                        bool   isVerb    = false;
                        string firstWord = words[0].Text;

                        // we have to determine if the first word is a verb
                        isVerb = IsVerb(firstWord);

                        // remove the first word
                        words.RemoveAt(0);
                    }
                }

                // if there are one or more words
                if ((words != null) && (words.Count > 0))
                {
                    // now iterate the words
                    foreach (Word word in words)
                    {
                        sb.Append(" " + word.Text);
                    }
                }

                // Trim
                description = sb.ToString().Trim();
            }

            // replace out any double spaces with a  single space
            description = description.Replace("  ", " ");

            // return value
            return(description);
        }