From 7c283d2e2e44d39e752b6ab3d4a9f76a768d02bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20=C5=A0t=C3=A1gl?= Date: Wed, 8 Jan 2025 05:56:48 +0100 Subject: [PATCH] Update README.md --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cdc95d..c983e90 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,20 @@ var clone = FastCloner.DeepClone(new { Hello = "world", MyList = new List { ## Advanced usage -Appart from deep cloning, FastCloner supports shallow cloning and deep cloning _to_ target: +Sometimes you might want to exclude certain fields & properties from cloning: +```csharp +private class TestPropsWithIgnored +{ + public int A { get; set; } = 10; + [DeepCloneIgnore] // <-- decorate such members with [DeepCloneIgnore] + public string B { get; set; } = "My string"; +} + +TestPropsWithIgnored original = new TestPropsWithIgnored { A = 42, B = "Test value" }; +TestPropsWithIgnored clone = original.DeepClone(); // clone.B is null (default value of a given type) +``` + +Apart from deep cloning, FastCloner supports shallow cloning and deep cloning _to_ target: ```csharp // the list is shared between the two instances