Romain

Romain

  • NA
  • 76
  • 39.9k

Serialization/Deserialization with ISerializable

Oct 28 2020 4:59 AM
Good morning,
I am working on a C# application and I need to serialize an object with ISerializable interface but
I do not how to do it. My object has no properties, it just have some methods. See below the code :
  1. public interface ILogger  
  2. {  
  3.   void logErrorMessage(string errorMessage);  
  4.   void logInfoMessage(string infoMessage);  
  5.   void logWarningMessage(string warningMessage);  
  6. }  
  7.   
  8.   
  9. [Serializable]  
  10. class MessageLogger: ILogger, ISerializable  
  11. {  
  12.   
  13.   public MessageLogger()  
  14.   { }  
  15.   
  16.   public void logErrorMessage(string errorMessage)  
  17.   {  
  18.     System.Diagnostics.Debug.WriteLine("ERROR :" + errorMessage);  
  19.   }  
  20.   
  21.   public void logInfoMessage(string infoMessage)  
  22.   {  
  23.     System.Diagnostics.Debug.WriteLine("INFO:" + infoMessage);  
  24.   }  
  25.   
  26.   public void logWarningMessage(string warningMessage)  
  27.   {  
  28.     System.Diagnostics.Debug.WriteLine("WARNING:" + warningMessage);  
  29.   }  
  30.   
  31.   public virtual void GetObjectData(SerializationInfo info, StreamingContext context)  
  32.   {  
  33.   }  
  34. }  
My question is what I have to put in GetObjectData ?
 
Thank you in advance for any help.
 
Romain. 

Answers (2)