Page 1 of 1

Attributes to save field by reference, value or both

Posted: Sun Aug 16, 2020 9:14 am
by Joel
Status

Requested

Complexity

5/10

Description

Attributes which can be added to a field to determine whether it is stored by reference, value or both during the serialisation process.

Re: Attributes to save field by reference, value or both

Posted: Fri Mar 26, 2021 6:55 pm
by RemDust
I actually came to the forum to request it ^^
Kinda surprise it doesn't have more votes :(

Re: Attributes to save field by reference, value or both

Posted: Tue Mar 22, 2022 5:28 pm
by giltar
I really wonder how do people solve this, since it is not implemented yet...:=/

Re: Attributes to save field by reference, value or both

Posted: Tue Mar 22, 2022 5:49 pm
by Joel
giltar wrote: Tue Mar 22, 2022 5:28 pm I really wonder how do people solve this, since it is not implemented yet...:=/
Hi there,

To do this you would create an ES3Type (see https://docs.moodkie.com/easy-save-3/es ... g-es3types), and then modify the writer.WriteProperty calls in ES3Type to include the memberReferenceMode parameter.

I.e. instead of this:

Code: Select all

writer.WritePropertyByRef("dict", instance.dict);
Use this:

Code: Select all

writer.WriteProperty("dict", instance.dict, ES3.ReferenceMode.ByRefAndValue);
However, we've seen very few situations where people have needed to do this over the past 10 or so years we've been doing this, which is why it's not explicitly documented and hasn't been implemented as attributes.

All the best,
Joel