Skip to content

Commit 918a1c4

Browse files
committed
Update README.md
1 parent 71f8bdd commit 918a1c4

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The **.NET ObjectFiller** also supports IEnumerable<T> (and all derivations) and
2121
- [Fill objects with constructor arguments](#fill-objects-with-constructor-arguments)
2222
- [Fill Interface-Properties](#fill-interface-properties)
2323
- [Fill Lists and Dictionaries](#fill-lists-and-dictionaries)
24-
- [Detect Circular Dependencies](#detect-circular-dependencies
24+
- [Detect Circular Dependencies](#detect-circular-dependencies)
2525
- [Mix all up](#mix-all-up)
2626
- [Available Plugins](#available-plugins)
2727
- [IntRangePlugin](#rangeintegerplugin)
@@ -428,6 +428,35 @@ YES! And ObjectFiller can handle that. Just say **```.Register<T>()```** after y
428428

429429
It is also really easy possible to fill **```Dictionary```** and **```Lists```** objects.
430430

431+
###Detect Circular Dependencies
432+
433+
The ObjectFiller is able to detect circulare references. You can specify that the ObjectFiller will ignore the circular references or throw an exception when a circular reference occurs.
434+
435+
```csharp
436+
437+
public class Children
438+
{
439+
public Parent Parent { get; set; }
440+
}
441+
442+
public class Parent
443+
{
444+
public List<Children> Childrens { get; set; }
445+
}
446+
447+
public class HelloFiller
448+
{
449+
public void FillPerson()
450+
{
451+
Filler<Parent> pFiller = new Filler<Parent>();
452+
pFiller.Setup().OnCircularReference().ThrowException(false);
453+
454+
Parent filledParent = pFiller.Create();
455+
}
456+
}
457+
```
458+
Here you can see that a parent has a ```List<Children>``` and the ```Children``` has a ```Parent``` - a circular reference. The ObjectFiller detects that and doesn't fill the circular object anymore! When you call ```.Setup().OnCircularReference().ThrowException(true);``` with the ```true``` flag it will raise an exception instead of just ignore the circular reference.
459+
431460
###Mix all up
432461

433462
```csharp

0 commit comments

Comments
 (0)