Technical Preparation:
1.dotnet Basic development;
The basic use of 2.WCF Data contract and service contract
Content:
We all know that the data contract is also server-side to client serialization and deserialization, such serialization is similar to the ASP.net ajax access WebService. ASP.net ajax Typically, the server-side data is serialized into a Jason string passed to the foreground script, but we might want to control some data contracts filed or attributes when serializing or deserializing. This requires us to listen to some of the events that the data contract triggers when serializing and deserializing.
Events for data contracts
The data contract has four separate events in serialization and deserialization:
1.serializing event: occurs before serialization;
2.serialized event: Occurs after serialization;
3.deserializing event: Before deserialization;
4.deserialized event: After deserialization;
We can understand the four events at a glance. But how do we monitor these events, WCF provides four attribute identities to identify the specific event that one of our defined methods is to listen for identities. But when we define a method, we have to conform to the type of the delegate of these events, that is, we must have the same parameters. Let's look at the form of the definition:
1. Monitor Serializing Events:
[OnSerializing]
void OnSerializing (StreamingContext context)
2. Monitor serialized events:
[OnSerialized]
void OnSerialized (StreamingContext context)
3. Monitor deserializing events:
[OnDeserializing]
void OnDeserializing (StreamingContext context)