Skip to content

Commit 0a78706

Browse files
committed
Update README.md
1 parent f3256ae commit 0a78706

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,37 @@ Its also really easy to write a plugin by yourself. I will show you that later.
166166
###Export ObjectFiller Settings
167167

168168
```csharp
169-
public class HelloFiller
170-
{
171-
private FillerSetup _fillerSetup;
172-
public HelloFiller()
169+
public class Person
173170
{
174-
Filler<Person> pFiller = new Filler<Person>();
171+
public string Name { get; set; }
172+
public string LastName { get; set; }
173+
public int Age { get; set; }
174+
public DateTime Birthday { get; set; }
175+
}
175176

176-
_fillerSetup = pFiller.Setup()
177-
.OnProperty(x => x.LastName).Use(new RealNames(RealNameStyle.LastNameOnly))
178-
.OnProperty(x => x.Name).Use(new RealNames(RealNameStyle.FirstNameOnly))
179-
.OnType<int>().Use(new IntRange(18, 75))
180-
.Result;
177+
public class HelloFiller
178+
{
179+
private FillerSetup _fillerSetup;
180+
public HelloFiller()
181+
{
182+
Filler<Person> pFiller = new Filler<Person>();
181183

184+
_fillerSetup = pFiller.Setup()
185+
.OnProperty(x => x.LastName).Use(new RealNames(RealNameStyle.LastNameOnly))
186+
.OnProperty(x => x.Name).Use(new RealNames(RealNameStyle.FirstNameOnly))
187+
.OnType<int>().Use(new IntRange(18, 75))
188+
.Result;
182189

183-
}
184-
public void FillPerson()
185-
{
186-
Filler<Person> pFiller = new Filler<Person>();
187-
pFiller.Setup(_fillerSetup);
188190

189-
Person filledPerson = pFiller.Create();
191+
}
192+
public void FillPerson()
193+
{
194+
Filler<Person> pFiller = new Filler<Person>();
195+
pFiller.Setup(_fillerSetup);
196+
197+
Person filledPerson = pFiller.Create();
198+
}
190199
}
191-
}
192200
```
193201
Here we can see that i created the filler setup in the constructor and save the ```.Result``` of the filler setup to a private field. In the method ```FillPerson()``` we call the ```.Setup(_fillerSetup)``` with the setup of this private field! Thats good if you want to reuse your setup!
194202

0 commit comments

Comments
 (0)