A collection of Random sentences/words/paragraphs etc. related resources.
コード例 #1
0
        /// <summary>
        ///   Gets a random FlatHash.com image URL.
        /// </summary>
        /// <param name="slug">The optional slug to use instead of generating a new random slug.</param>
        /// <param name="format">The image format to use.</param>
        /// <returns>The random image URL.</returns>
        /// <seealso cref="RoboHash.Image(string, string, RoboHashImageFormat, string)" />
        public static string Image(string slug = null, FlatHashImageFormat format = FlatHashImageFormat.png)
        {
            slug = slug ?? string.Join(string.Empty, Lorem.Words(3));

            return("http://flathash.com/{0}.{1}".FormatCulture(slug, format));
        }
コード例 #2
0
        public static string Slug(string words = null, string glue = null)
        {
            glue = glue ?? new[] { "_", ".", "-" }.Random();

            return((words ?? string.Join(" ", Lorem.Words(2))).Replace(" ", glue).ToLowerInvariant());
        }
コード例 #3
0
        /// <summary>
        /// Get a random `Exception` with a fake stack trace.
        /// </summary>
        /// <returns>A <see cref="Exception"/></returns>
        public static Exception Exception()
        {
            Exception exe = null;

            switch (Number.RandomNumber(11))
            {
            case 0:
                try
                {
                    throw new ArgumentException(Lorem.Sentence(), Lorem.Word());
                }
#pragma warning disable CA1031 // Used elsewhere
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 1:
                try
                {
                    throw new ArgumentNullException(Lorem.Word(), Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 2:
                try
                {
                    throw new BadImageFormatException(Lorem.Sentence(), Lorem.Word());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 3:
                try
                {
                    throw new IndexOutOfRangeException(Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 4:
                try
                {
                    throw new ArithmeticException(Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 5:
                try
                {
                    throw new OutOfMemoryException(Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 6:
                try
                {
                    throw new FormatException(Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 7:
                try
                {
                    throw new DivideByZeroException();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 8:
                try
                {
                    throw new EndOfStreamException(Lorem.Sentence());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 9:
                try
                {
                    throw new FileNotFoundException("File not found...", Path.GetRandomFileName());
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 10:
                try
                {
                    throw new NotImplementedException();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;

            case 11:
                try
                {
                    throw new UnauthorizedAccessException();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    exe = e;
                }
#pragma warning restore CA1031 // Do not catch general exception types

                break;
            }

            return(exe);
        }