Skip to main content
Home Forums Silverlight Programming Programming with .NET - General JSON Serialization and == question
2 replies. Latest Post by Grofit on July 8, 2009.
(0)
Grofit
Member
229 points
310 Posts
07-07-2009 7:51 AM |
Hey,
Ive got some objects that are passed around through WCF services and back, one of them is a token that contains a hash and an id. Now the service persists these objects in memory for active users. Then when a user subscribes they are handed one of these tokens to basically verify that they are a valid user when starting other services...
The problem i have is that the flow seems correct but when unserializing the objects dont appear to be the same...
- Contact Service
- Service Generates and Stores Unique Token
- Service Serializes Token to Client
- Client Unserializes Token
- Client Stores Token
- Client Serializes token
- Client Calls Other Service With Serialized Token
- New Service Unserializes Token
- New Service Compares New Token Against All Active Tokens In Memory
Its at this point it does the TokenList == UnserializedToken, and although i can see them both containing the same data they dont match, im assuming its down to the fact that they are both 2 different objects in memory so it does a comparison on that rather than on the data contained... if thats the case would it be worth implementing the interface that overrides the Equals() method? Or is there something else that is wrong?
waldred
702 points
113 Posts
07-07-2009 9:10 PM |
Grofit:although i can see them both containing the same data they dont match, im assuming its down to the fact that they are both 2 different objects in memory so it does a comparison on that rather than on the data contained
My guess is that you're right about that.
I think you'll want to override Equals() or perform the equality check against whatever properties are appropriate in the 'New Service'.
07-08-2009 2:52 AM |
Thought so, thanks for confirming!