Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
NameValueCollection Serialization
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Adam Haskell  
View profile  
 More options Oct 11 2012, 10:36 am
From: Adam Haskell <a.hask...@gmail.com>
Date: Thu, 11 Oct 2012 07:36:00 -0700 (PDT)
Subject: NameValueCollection Serialization

I just upgraded my project from 1.4 driver to 1.6 driver and I had a
custom serializer for NameValueCollection (we're dumping a bunch of stuff
off the HTTP request to report on later). It seems now something is
registering EnumerableSerialzer for NameValueCollection. It seemed odd to
me that NameValueCollection would get serialized by an
Enumerable serializer and not a Dictionary serializer but I was glad to see
I could trash my custom serializer. Turns out it looks like the serializer
is not storing the collection correctly and (not surprisingly) I am getting
an error when it tries to deserialize (Enumerable class NameValueCollection
does not implement IList so it can't be deserialized)..

I'm 90% confident it is not my code registering the faulty serializer but I
have to admit to not being able to figure out where that mapping IS
happening. I figure I need to figure out how to get my custom serializer in
there, fork fix the pull request, or maybe (hopefully) someone can help me
out in understanding how EnumerableSerializers are the correct serializer
and I just need to configure it correctly.

Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Oct 11 2012, 11:23 am
From: Robert Stam <rob...@10gen.com>
Date: Thu, 11 Oct 2012 11:23:33 -0400
Local: Thurs, Oct 11 2012 11:23 am
Subject: Re: [mongodb-csharp] NameValueCollection Serialization

If you register your custom serializer for NameValueCollection the driver
should use your serializer.

There is no builtin serializer for NameValueCollection (there probably
should be...).

In the current version of the driver it's being serialized (by default) by
EnumerableSerializer because the NameValueCollection class implements
IEnumerable and not IDictionary.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Haskell  
View profile  
 More options Oct 11 2012, 1:02 pm
From: Adam Haskell <a.hask...@gmail.com>
Date: Thu, 11 Oct 2012 10:02:03 -0700 (PDT)
Local: Thurs, Oct 11 2012 1:02 pm
Subject: Re: [mongodb-csharp] NameValueCollection Serialization

I was originally registering my serializer, but after updating to 1.6 I
starting seeing an error on the call to RegisterSerializer. Unbeknownst to
me that code is being executed multiple times.

So solve the above mentioned error I wrapped that registration code with a
Serializer lookup:
 if(BsonSerializer.LookupSerializer(typeof(NameValueCollection)) == null)

The lookup always returned EnumerableSerializer. Seems that was a mistake;
Lookup is just finding whatever it would actually end up using and as a
result registers that as the serializer. I didn't think about looking to
see if RegisterSerializer implemented something different/new to throw
errors on duplicated registration (which based off my previous success with
this code on 1.4 I am thinking it didn't previously).

Thanks for re-enforcing my thought that there was nothing explicitly
registering EnumerableSerializer for NameValueCollection. For now I've
wrapped the code in a try/catch and ignored a Serialization error and I am
past that issue. Guess I have a new todo to find why this is being called
more than once. Thanks for the help Robert, I'll see if I can figure out
the internals enough to add my custom Serializer to the driver itself and
generate a pull request (Don't hold your breath though I just moved into a
new house so recreational programming sort of on hold right now :(  ) .

Adam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Oct 11 2012, 1:09 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Thu, 11 Oct 2012 10:09:03 -0700 (PDT)
Local: Thurs, Oct 11 2012 1:09 pm
Subject: Re: [mongodb-csharp] NameValueCollection Serialization

Yes, LookupSerializer is probably a poor choice as a name because, while
seemingly innocuous, it doesn't communicate the fact that it has an
unexpected side-effect of mutating internal state such that you can't
change the behavior later.  We will try and address this in future versions.

For now, you simply need to make sure that you call RegisterSerializer at
application startup/initialization before any serialization is performed.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Haskell  
View profile  
 More options Oct 11 2012, 1:35 pm
From: Adam Haskell <a.hask...@gmail.com>
Date: Thu, 11 Oct 2012 10:35:46 -0700 (PDT)
Local: Thurs, Oct 11 2012 1:35 pm
Subject: Re: [mongodb-csharp] NameValueCollection Serialization

Yeah I was going to ask a follow-up on that and see if there was a less
obnoxious lookup method :) Wrapping the code in a try and ignoring the
error upon duplicate registration works for now until I can get in there
and refactor that stuff to be called only on initialization.

Adam  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »