예제 #1
0
 public static RandomStringStockInfo FromStock(RandomStringStock stock)
 {
     try
     {
         return(map[stock]);
     }
     catch (KeyNotFoundException exception)
     {
         throw new PatternUsageErrorException(String.Format("The stock of predefined string values named '{0}' does not exist.", stock), exception);
     }
 }
예제 #2
0
            /// <summary>
            /// Returns an enumeration of random strings from a pre-existing stock of values.
            /// </summary>
            /// <param name="count">The number of strings to generate.</param>
            /// <param name="stock">A stock of preset values.</param>
            /// <returns>An enumeration of random string values.</returns>
            /// <exception cref="GenerationException">Thrown if the specified parameters are inconsistent or invalid.</exception>
            public static IEnumerable <string> Strings(int count, RandomStringStock stock)
            {
                var generator = new RandomStockStringGenerator
                {
                    Count  = count,
                    Values = RandomStringStockInfo.FromStock(stock).GetItems(),
                };

                foreach (string value in generator.Run())
                {
                    yield return(value);
                }
            }
            /// <summary>
            /// Returns an enumeration of random strings from a pre-existing stock of values.
            /// </summary>
            /// <param name="count">The number of strings to generate.</param>
            /// <param name="stock">A stock of preset values.</param>
            /// <param name="seed">A seed value to initialize the random number generator.</param>
            /// <returns>An enumeration of random string values.</returns>
            /// <exception cref="GenerationException">Thrown if the specified parameters are inconsistent or invalid.</exception>
            public static IEnumerable<string> Strings(int count, RandomStringStock stock, int seed)
            {
                var generator = new RandomStockStringGenerator
                {
                    Count = count,
                    Values = RandomStringStockInfo.FromStock(stock).GetItems(),
                    Seed = seed,
                };

                foreach (string value in generator.Run())
                    yield return value;
            }
예제 #4
0
 public static RandomStringStockInfo FromStock(RandomStringStock stock)
 {
     try
     {
         return map[stock];
     }
     catch (KeyNotFoundException exception)
     {
         throw new PatternUsageErrorException(String.Format("The stock of predefined string values named '{0}' does not exist.", stock), exception);
     }
 }
예제 #5
0
 private RandomStringStockInfo(RandomStringStock stock, string databaseResource)
 {
     this.stock = stock;
     this.databaseResource = databaseResource;
 }
예제 #6
0
 private RandomStringStockInfo(RandomStringStock stock, string databaseResource)
 {
     this.stock            = stock;
     this.databaseResource = databaseResource;
 }