Skip to content

Commit

Permalink
Add an example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailshilkov committed May 4, 2016
1 parent 31ac8c4 commit 1ddfcbf
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,73 @@ https://nuget.org/packages/With.Fody/

## Your Code

TODO
public class MyClass
{
public MyClass(int intValue, string stringValue, OtherClass c1, OtherClass c2)
{
this.IntValue = intValue;
this.StringValue = stringValue;
this.C1 = c1;
this.C2 = c2;
}

public int IntValue { get; }

public string StringValue { get; }

public OtherClass C1 { get; }

public OtherClass C2 { get; }

// Needed for IntelliSense/Resharper support
public MyClass With(int value) => this;
// If two properties have same type, we need to append the property name to With
public MyClass WithC1(OtherClass value) => this;
public MyClass WithC2(OtherClass value) => this;
}

## What gets compiled

TODO
public class MyClass
{
public MyClass(int intValue, string stringValue, OtherClass c1, OtherClass c2)
{
this.IntValue = intValue;
this.StringValue = stringValue;
this.C1 = c1;
this.C2 = c2;
}

public int IntValue { get; }

public string StringValue { get; }

public OtherClass C1 { get; }

public OtherClass C2 { get; }

public MyClass With(int value)
{
return new MyClass(value, this.StringValue, this.C1, this.C2);
}

public MyClass With(string value)
{
return new MyClass(this.IntValue, value, this.C1, this.C2);
}

// If two properties have same type, we need to append the property name to With
public MyClass WithC1(OtherClass value)
{
return new MyClass(this.IntValue, this.StringValue, value, this.C2);
}

public MyClass WithC2(OtherClass value)
{
return new MyClass(this.IntValue, this.StringValue, this.C1, value);
}
}


## Icon

Expand Down

0 comments on commit 1ddfcbf

Please sign in to comment.