forked from JamesNK/Newtonsoft.Json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerializationCallbacks.aml
58 lines (52 loc) · 3.12 KB
/
SerializationCallbacks.aml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="utf-8"?>
<topic id="SerializationCallbacks" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<!-- Uncomment this to generate an outline of the section and sub-section
titles. Specify a numeric value as the inner text to limit it to
a specific number of sub-topics when creating the outline. Specify
zero (0) to limit it to top-level sections only. -->
<!-- <autoOutline /> -->
<para>Json.NET supports serialization callback methods. A callback can be used to manipulate an object before and after its serialization and deserialization by the JsonSerializer.</para>
<list class="bullet">
<listItem><para><legacyBold>OnSerializing</legacyBold></para></listItem>
<listItem><para><legacyBold>OnSerialized</legacyBold></para></listItem>
<listItem><para><legacyBold>OnDeserializing</legacyBold></para></listItem>
<listItem><para><legacyBold>OnDeserialized</legacyBold></para></listItem>
</list>
<para>
To tell the serializer which methods should be called during the object's
serialization lifecycle, decorate a method with the appropraite attribute
(<codeEntityReference>T:System.Runtime.Serialization.OnSerializingAttribute</codeEntityReference>,
<codeEntityReference>T:System.Runtime.Serialization.OnSerializedAttribute</codeEntityReference>,
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializingAttribute</codeEntityReference>,
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializedAttribute</codeEntityReference>).
</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline />, add an address attribute to identify it
and specify a title so that it can be jumped to with a hyperlink. -->
<section>
<title>Example</title>
<content>
<!-- Uncomment this to create a sub-section outline
<autoOutline /> -->
<para>Example object with serialization callback methods:</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializationCallbacksObject" title="Serialization Callback Attributes" />
<para>The example object being serialized and deserialized by Json.NET:</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializationCallbacksExample" title="Serialization Callback Example" />
</content>
</section>
<relatedTopics>
<codeEntityReference>T:System.Runtime.Serialization.OnSerializingAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnSerializedAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializingAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializedAttribute</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>