Skip to content

Instantly share code, notes, and snippets.

@thunklife
Created December 27, 2011 21:00
Show Gist options
  • Select an option

  • Save thunklife/1525089 to your computer and use it in GitHub Desktop.

Select an option

Save thunklife/1525089 to your computer and use it in GitHub Desktop.
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;
}
}
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