Example #1
0
        /// <summary>
        /// Generates 'count' paragraphs of lipsum text.
        /// </summary>
        /// <param name="count">The number of paragraphs desired.</param>
        /// <param name="options">Used to determine the minimum and maximum sentences per paragraphs, and format string if applicable.</param>
        /// <returns></returns>
        public string[] GenerateParagraphs(int count, Paragraph options)
        {
            /*
             * TODO:  These generate methods could probably be
             * refactored into one method that takes a count
             * and a TextFeature. */
            string[] paragraphs = new string[count];
            string[] sentences  = new string[] { };
            for (int i = 0; i < count; i++)
            {
                /* Get a random amount of sentences based on the
                 * min and max from the paragraph options */
                sentences = GenerateSentences(LipsumUtilities.
                                              RandomInt((int)options.GetMinimum(), (int)options.GetMaximum()));

                // Shove them all together in sentence fashion.
                string joined = String.Join(options.Delimiter, sentences);

                // Format if allowed.
                paragraphs[i] = String.IsNullOrEmpty(options.FormatString) ?
                                joined : options.Format(joined);
            }

            return(paragraphs);
        }
Example #2
0
        /// <summary>
        /// Generates 'count' sentences of lipsum text.
        /// If options.FormatString is not null or empty that string used to format the sentences.
        /// </summary>
        /// <param name="count">The number of sentences desired.</param>
        /// <param name="options">Used to determine the minimum and maximum words per sentence, and format string if applicable.</param>
        /// <returns></returns>
        public string[] GenerateSentences(int count, Sentence options)
        {
            string[] sentences = new string[count];
            string[] words     = new string[] { };

            for (int i = 0; i < count; i++)
            {
                /* Get a random amount of words based on the
                 * min and max from the Sentence options */
                words = GenerateWords(LipsumUtilities.
                                      RandomInt((int)options.MinimumWords, (int)options.MaximumWords));

                // Shove them all together in sentence fashion.
                string joined = String.Join(options.Delimiter, words);

                // Format if allowed.
                sentences[i] = String.IsNullOrEmpty(options.FormatString) ?
                               joined : options.Format(joined);
            }

            return(sentences);
        }