Example #1
0
        protected override DataSet CreateDataSet()
        {
            DataSet result = new DataSet();

            if (!String.IsNullOrEmpty(ConnectionString))
            {
                MeGonnaBeRandomConnectionStringBuilder sb = new MeGonnaBeRandomConnectionStringBuilder();
                sb.ConnectionString = ConnectionString;

                int count = sb.RowCount;

                List <IRandomGenerator> generators = new List <IRandomGenerator>();
                DataTable table = new DataTable("Table1");

                foreach (string str in sb.Generators)
                {
                    string[] args = str.Split(':').Select(t => t.Trim()).ToArray();

                    IRandomGenerator generator = Utils.Get(args[1]);
                    if (generator != null)
                    {
                        generator            = generator.Create();
                        generator.ColumnName = args[0];


                        table.Columns.Add(generator.ColumnName, generator.Type);

                        generators.Add(generator);
                    }
                }

                for (int i = 0; i < count; i++)
                {
                    DataRow row = table.NewRow();
                    foreach (IRandomGenerator generator in generators)
                    {
                        row[generator.ColumnName] = generator.Next();
                    }
                    table.Rows.Add(row);
                }



                result.Tables.Add(table);
            }

            return(result);
        }
        protected override void SetConnectionString(string value)
        {
            if (!String.IsNullOrEmpty(value))
            {
                MeGonnaBeRandomConnectionStringBuilder sb = new MeGonnaBeRandomConnectionStringBuilder();
                sb.ConnectionString = value;

                numericUpDown1.Value = sb.RowCount;

                generatorsLB.Items.Clear();

                foreach (string generator in sb.Generators)
                {
                    generatorsLB.Items.Add(generator);
                }
            }
        }
        protected override string GetConnectionString()
        {
            MeGonnaBeRandomConnectionStringBuilder result = new MeGonnaBeRandomConnectionStringBuilder();

            result.RowCount = (int)numericUpDown1.Value;

            List <string> generators = new List <string>();

            foreach (object generator in generatorsLB.Items)
            {
                generators.Add(generator.ToString());
            }

            result.Generators = generators.ToArray();


            return(result.ToString());
        }