@@ -34,6 +34,11 @@ public class Filler<T>
3434 /// </summary>
3535 private readonly SetupManager setupManager ;
3636
37+ /// <summary>
38+ /// True when the filler will just fill properties which are set up explicit
39+ /// </summary>
40+ private bool justConfiguredProperties ;
41+
3742 #endregion
3843
3944 #region Constructors and Destructors
@@ -117,7 +122,17 @@ public T Fill(T instanceToFill)
117122 /// <returns>Fluent API setup</returns>
118123 public FluentFillerApi < T > Setup ( )
119124 {
120- return this . Setup ( null ) ;
125+ return this . Setup ( false ) ;
126+ }
127+
128+ /// <summary>
129+ /// Call this to start the setup for the <see cref="Filler{T}"/>
130+ /// </summary>
131+ /// <param name="explicitSetup">True if just properties shall get filled which configured in filler setup.</param>
132+ /// <returns>Fluent API setup</returns>
133+ public FluentFillerApi < T > Setup ( bool explicitSetup )
134+ {
135+ return this . Setup ( null , explicitSetup ) ;
121136 }
122137
123138 /// <summary>
@@ -131,12 +146,29 @@ public FluentFillerApi<T> Setup()
131146 /// Fluent API Setup
132147 /// </returns>
133148 public FluentFillerApi < T > Setup ( FillerSetup fillerSetupToUse )
149+ {
150+ return this . Setup ( fillerSetupToUse , false ) ;
151+ }
152+
153+ /// <summary>
154+ /// Call this to start the setup for the <see cref="Filler{T}"/> and use a setup which you created
155+ /// before with the <see cref="IFluentApi{TTargetObject,TTargetType}"/>
156+ /// </summary>
157+ /// <param name="fillerSetupToUse">
158+ /// FillerSetup to use
159+ /// </param>
160+ /// <param name="explicitSetup">True if just properties shall get filled which configured in filler setup.</param>
161+ /// <returns>
162+ /// Fluent API Setup
163+ /// </returns>
164+ public FluentFillerApi < T > Setup ( FillerSetup fillerSetupToUse , bool explicitSetup )
134165 {
135166 if ( fillerSetupToUse != null )
136167 {
137168 this . setupManager . FillerSetup = fillerSetupToUse ;
138169 }
139170
171+ this . justConfiguredProperties = explicitSetup ;
140172 return new FluentFillerApi < T > ( this . setupManager ) ;
141173 }
142174
@@ -648,6 +680,12 @@ private void FillInternal(object objectToFill, HashStack<Type> typeTracker = nul
648680 continue ;
649681 }
650682
683+ if ( this . justConfiguredProperties
684+ && ! this . setupManager . FillerSetup . TypeToFillerSetup . ContainsKey ( property . PropertyType ) )
685+ {
686+ continue ;
687+ }
688+
651689 object filledObject = this . CreateAndFillObject ( property . PropertyType , currentSetup , typeTracker ) ;
652690
653691 this . SetPropertyValue ( property , objectToFill , filledObject ) ;
0 commit comments