Created
December 27, 2011 21:00
-
-
Save thunklife/1525089 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class PersonFactory | |
| { | |
| public static FirstNameExpression CreatePerson() | |
| { | |
| return new FirstNameExpression(new Person()); | |
| } | |
| } | |
| public class FirstNameExpression | |
| { | |
| private Person _person; | |
| public FirstNameExpression(Person person) | |
| { | |
| _person = person; | |
| } | |
| public Person WithFirstName(string first) | |
| { | |
| _person.FirstName = first; | |
| return _person; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Person | |
| { | |
| public string FirstName { get; set; } | |
| public string LastName { get; set; } | |
| public string MiddleName { get; set; } | |
| public Person WithMiddleName(string middle) | |
| { | |
| this.MiddleName = middle; | |
| return this; | |
| } | |
| public Person WithLastName(string last) | |
| { | |
| this.LastName = last; | |
| return this; | |
| } | |
| public override string ToString() | |
| { | |
| return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment