On my client side, I want the default C# constructors from my WCF service C# classes. There reason we want to do this is to have the default values from the server side classes on the client side. From the searches I've done, there are 2 ways to go about this:
Is either one of these the "better" option? or is this heavily dependent on how often I would need a new instance of the object?
EDIT: We tried using [System.Runtime.Serialization.OnDeserialized]
seen here but it's not working. We are also not using the DataContract
attribute in our class, we use ServiceKnownType
instead
I think you can try using OnDeserializing
attribute
[System.Runtime.Serialization.OnDeserializing]
private void OnDeserializing(StreamingContext ctx)
{
// Here set your default values
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.