Encode method for DataContractCodec