Example #1
0
        /// <summary>
        /// Try to convert the name of a method to useful comment.
        /// </summary>
        /// <param name="name">The name of the method.</param>
        /// <returns>The comment.</returns>
        public static string Method(string name)
        {
            var special = CheckForSpecialMethodNames(name);

            if (special != null)
            {
                return(special);
            }

            var parts = SplitName(name);

            if (parts.Length > 0)
            {
                // if name of method starts with "on", assuming it is a raise event method
                if (parts[0].Equals("on", StringComparison.OrdinalIgnoreCase))
                {
                    MakeLowerCase(parts, false);

                    return("Raises the " + string.Join(" ", parts.Skip(1)) + " event.");
                }

                if (Verbs.IsVerb(parts[0]))
                {
                    MakeLowerCase(parts, false);

                    if (parts.Length > 1)
                    {
                        return(parts[0] + " the " + string.Join(" ", parts.Skip(1)) + '.');
                    }

                    return(parts[0] + '.');
                }

                MakeLowerCase(parts, true);

                if (parts.Length > 1)
                {
                    return("The " + string.Join(" ", parts) + '.');
                }

                return("The " + parts[0] + '.');
            }

            return("The " + name.ToLower() + '.');
        }
Example #2
0
        /// <summary>
        /// Try to convert the name of a delegate to useful comment.
        /// </summary>
        /// <param name="name">The name of the delegate.</param>
        /// <returns>The comment.</returns>
        public static string Delegate(string name)
        {
            var special = CheckForSpecialMethodNames(name);

            if (special != null)
            {
                return(special);
            }

            var parts = SplitName(name);

            if (parts.Length > 0)
            {
                if (Verbs.IsVerb(parts[0]))
                {
                    MakeLowerCase(parts, false);

                    if (parts.Length > 1)
                    {
                        return(parts[0] + ' ' + string.Join(" ", parts.Skip(1)) + '.');
                    }

                    return(parts[0] + '.');
                }

                MakeLowerCase(parts, true);

                if (parts.Length > 1)
                {
                    if (parts[parts.Length - 1].Contains("delegate"))
                    {
                        return("The " + string.Join(" ", parts) + '.');
                    }

                    return("The " + string.Join(" ", parts) + " delegate.");
                }

                return("The " + parts[0] + '.');
            }

            return("The " + name.ToLower() + '.');
        }