Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I modify a value just before the serialization or just after the deserialization?

0
Posted

How can I modify a value just before the serialization or just after the deserialization?

0

You can add custom attribute to some method. Your marked method will get called a the right time. This is usefull to initialize a property after the deserialization or to clean up your instance before the serialization. • OnDeserializingAttribute :This event happens before deserialization • OnDeserializedAttribute :This event happens after deserialization • OnSerializingAttribute :This event happens before serialization • OnSerializedAttribute :This even happens after serialization [Serializable] public class SecurityToken { private string password; private string userName; private string Decrypt(string aPassword) { // Decrypt the password here !!! return password; } private string Encrypt(string aPassword) { // Encrypt the password here !!!

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123