Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




QuestPond’s Interview Questions & Answers on learning serialization events

In case of DataContractserialzier, during serialization and deserialization constructor won’t get invoked. However DataContractserializer supports callbacks which we can use for initialization.

These callbacks works with the help of some special attributes

  • OnDeserializedAttribute– Marks method to be invoked immediately after the object is deserialized.
  • OnDeserializingAttribute – Marks method to be invoked during deserialization of an object.
  • OnSerializedAttribute– Marks method to be invoked immediately after the object is Serialized.
  • OnSerializingAttribute – Marks method to be invoked during Serialization of an object.

    [DataContract]
    public class MyData
      {
        [DataMember]
    publicintdata1;
    
        [OnDeserialized]
    voidOnDeserialized(StreamingContext c)
        {
        }
    
        [OnDeserializing]
    voidOnDeserializing(StreamingContext c)
        {
        }
    
        [OnSerialized]
    voidOnSerialized(StreamingContext c)
        {
        }
    
        [OnSerializing]
    voidOnSerializing(StreamingContext c)
        { 
        }
      }
    

For technical trainings on various topics like WCF, MVC, Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact SukeshMarla@Gmail.com or visit www.sukesh-marla.com

For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla

See following video on WCF(Windows Communication Foundation) One way contract: -

Click and see here for more training on WCF(Windows Communication Foundation).
 

Helpful Website Url
http://questpond.com/
Share this article   |    Print    |    Article read by 3013 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles: No related article
Related Interview Questions: No related interview question