Created
March 24, 2019 21:26
-
-
Save jakesays-old/8f2b0b4f374eee7fc1a677ac5ff470b6 to your computer and use it in GitHub Desktop.
This file contains 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
//externally exposed data object | |
public partial class Person | |
{ | |
public string FirstName { get; private set; } | |
public string LastName { get; private set; } | |
} | |
public partial class Person | |
{ | |
internal struct Builder | |
{ | |
private Person _instance; | |
public Builder(Person instance) | |
{ | |
_instance = instance; | |
} | |
public string FirstName | |
{ | |
get => _instance.FirstName; | |
set => _instance.FirstName = value; | |
} | |
public string LastName | |
{ | |
get => _instance.LastName; | |
set => _instance.LastName = value; | |
} | |
} | |
} | |
void EditPerson(Person p) | |
{ | |
//using the builder | |
Person.Builder builder(p); | |
builder.FirstName = "foo"; | |
builder.LastName = "bar"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment