File tree Expand file tree Collapse file tree 2 files changed +11
-34
lines changed
Expand file tree Collapse file tree 2 files changed +11
-34
lines changed Original file line number Diff line number Diff line change @@ -14,28 +14,11 @@ public class Employee
1414 [ FluentMember ( 0 ) ]
1515 public string Name { get ; private set ; }
1616
17- public List < Job > Jobs { get ; private set ; } = new List < Job > ( ) ;
18-
19- public List < Phone > Phones { get ; private set ; } = new List < Phone > ( ) ;
20-
21- [ FluentMethod ( 1 ) ]
22- [ FluentContinueWith ( 1 ) ]
23- public void HavingJob ( Func < CreateJob . ICreateJob , Job > createJob )
24- {
25- Jobs . Add ( createJob ( CreateJob . InitialStep ( ) ) ) ;
26- }
27-
28- [ FluentMethod ( 1 ) ]
29- [ FluentContinueWith ( 1 ) ]
30- public void HavingPhone ( Func < CreatePhone . ICreatePhone , Phone > createPhone )
31- {
32- Phones . Add ( createPhone ( CreatePhone . InitialStep ( ) ) ) ;
33- }
34-
35- [ FluentMethod ( 1 ) ]
36- private void Build ( )
37- {
38- }
17+ [ FluentCollection ( 1 , "Phone" ) ]
18+ public List < Phone > Phones { get ; private set ; }
19+
20+ [ FluentCollection ( 2 , "Job" ) ]
21+ public List < Job > Jobs { get ; private set ; }
3922}
4023
4124[ FluentApi ]
Original file line number Diff line number Diff line change 8383
8484Console . WriteLine ( dockerFile ) ;
8585
86- // Person
86+ // Employee
8787//
8888// Example from https://stackoverflow.com/questions/59021513/using-fluent-interface-with-builder-pattern.
8989//
9090
9191Employee employee = CreateEmployee
9292 . WithName ( "My Name" )
93- . HavingPhone ( p => p
94- . WithNumber ( "222-222-2222" )
95- . WithUsage ( "CELL" ) )
96- . HavingJob ( j => j
97- . WithCompanyName ( "First Company" )
98- . WithSalary ( 100 ) )
99- . HavingJob ( j => j
100- . WithCompanyName ( "Second Company" )
101- . WithSalary ( 200 )
102- )
103- . Build ( ) ;
93+ . WithPhone (
94+ p => p . WithNumber ( "222-222-2222" ) . WithUsage ( "CELL" ) )
95+ . WithJobs (
96+ j => j . WithCompanyName ( "First Company" ) . WithSalary ( 100 ) ,
97+ j => j . WithCompanyName ( "Second Company" ) . WithSalary ( 200 ) ) ;
10498
10599Console . WriteLine ( JsonSerializer . Serialize ( employee ) ) ;
106100
You can’t perform that action at this time.
0 commit comments