-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve instance reference relationships by tagging instance IDs #244
base: master
Are you sure you want to change the base?
Conversation
Thanks again for the PR. Here are some thoughts after going through the code. 1. YAXSerializationOptions1.1 Competing options1.1.1 With this PR we have have
They can be set at the same time, which is ambiguous. This is disadvantage of using 1.1.2 Looking at the Json.NET implementation, they are usinga) 1.1.3 Solution for YAXLibSo we could add a property a) b) YAXLib/YAXLibTests/SerializationTestBase.cs Lines 2668 to 2690 in 19b6d61
c) 1.2 Not implemented optionOption
Possible solution: When this option is set, we fall back to 2. Exception
|
Hi @strugglesharp |
8a9c495
to
87dbac2
Compare
For instance tag ObjId, realize the serialization of circular reference or multiple references
For instance tag ObjId, realize the serialization of circular reference or multiple references.
在几乎序列化类库中, 都没有指出相同的实例引用在xml中的对应关系. 这就造成了两个问题:
In almost all serialized class libraries, the correspondence of the same instance reference in XML is not indicated. This creates two problems.
A->B->C->A will cause an infinite loop when serializing, even if our instances are finite.
After multiple references to the same instance, serialized and deserialized, the result is that their same reference relationship is not restored. For example, [A1, A1] becomes [A1,A2] after serialization and deserialization
I tagged the instance with the ID, which solved the problem.
The test samples illustrates the functionality more clearly. Note the _ObjId=XXX.
Example1:
The result of serialization is
Deserialization can also pass
Example2:
The result of serialization is
Deserialization can also pass