Hi,
I have a DataContract class, on which I have defined 4 event handler methods as shown below:
//[OnSerializing] and [OnSerialized] marked method not getting called
DataContract class
- [DataContract]
- public class Customer
- {
- [DataMember]
- public int customerID;
- [DataMember]
- public string customerName;
- [DataMember]
- public long phoneNumber;
- [OnSerializing]
- private void OnSerializing(StreamingContext context)
- {
-
- }
- [OnSerialized]
- private void OnSerialized(StreamingContext context)
- {
-
-
-
-
- }
- [OnDeserializing]
- private void OnDeserializing(StreamingContext context)
- {
-
-
- customerName = "This is set again in OnDeserializing.";
- }
- [OnDeserialized]
- private void OnDeserialized(StreamingContext context)
- {
-
-
- customerName = "This is set again in OnDeserialized.";
- }
- }
Service class
- public class Booking : IBooking
- {
- public string bookTicket(Customer cust)
- {
- return String.Format("Dear {0}, your order has been received by us. " +
- "You will receive a confirmation SMS shortly on your phone no- {1}", cust.customerName, cust.phoneNumber);
- }
- }
Any ideas why the above 2 Serialization methods are not getting called when invoked through client.
Regards,
Deepak