While reading here and creating a large Object to send and receive using JsonWriter and JsonReader. I wanted to keep track of total bytes sent.
While reading here and creating a large Object to send and receive using JsonWriter
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s nothing in
JsonWriterorJsonReaderthat is going to provide that for you.Really the only way to do it would be to wrap/extend the
ReaderorWriteryou’re currently passing toJsonReader/JsonWriterand keep track of the bytes being read/written in/out.Edit to add: As an example you could do something like:
It’d be a lot cleaner if
Writerwas an interface but … meh, what can you do. If you know you’re only ever going to use one type ofWriter(say, aBufferedWriter) you could extend that, override all the methods and re-call the methods onthisinstead of the privaterealWriterinstance passed in via the constructor.