Examples - HowToThis page gives examples of how you use DataWang Create a list of random furniture1. Create your entity. Here is an entity that represents a piece of furniture. Notice the DataWangType attribute over the Name and Colour properties. These tell DataWang the category of data to generate for this property. public class FurnitureItem
{
[DataWangType(Category = "furniture")]
public string Name { get; set; }
[DataWangType(Category = "colours")]
public string Colour { get; set; }
public string NonWangProperty { get; set; }
}2. Call DataWang! We set up custom category providers for the furniture items and the colours based on the GoogleSetDataProvider() and we want 10 Furniture instances to be returned in our list. Notice the first parameter to each of the GoogleSetDataProvider objects matches the category name we applied to the entity properties. The remaining parameters are the "seed items" that we will send to Google Sets to help it generate our random data. var result = DataWang.ThatsDataWang<FurnitureItem>(10,
new PreloadedContainer(
new GoogleSetDataProvider("furniture",
"chair", "plate", "table", "sofa", "curtains"),
new GoogleSetDataProvider("colours",
"red", "blue","black", "orange", "pink")));3. Display results. result.ForEach(item =>
Trace.WriteLine(string.Format("{0}, colour {1}", item.Name, item.Colour)));The DbgView trace output is (formatted), | Name | Colour | | chair | red | | table | black | | sofa | orange | | cabinet | blue | | desk | white | | bed | brown | | bench | green | | bar%20stool | pink | | hutch | yellow | | workstation | gray |
Just get a list of stuff1. Providers return a List of string so you can invoke them directly to access this data. var result = new GoogleSetDataProvider("furniture",
"chair", "plate", "table", "sofa", "curtains").Generate(
new MockDataSetRequest(10));or var result = new EmailDataProvider().Generate(
new MockDataSetRequest(200));
|
id