From 1ddfcbf964f8179723cc697aeeaaa82e5798bd97 Mon Sep 17 00:00:00 2001 From: mikhailshilkov Date: Wed, 4 May 2016 16:37:58 +0200 Subject: [PATCH] Add an example to readme --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d32aaa9..ef185b4 100644 --- a/README.md +++ b/README.md @@ -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