Omega Red
unread,Feb 7, 2012, 2:14:57 PM2/7/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb...@googlegroups.com
I have one base Component class (which acts basically like an interface) and many classes that derive from it. In a collection I store elements that can contain arbitrary number of those derived Component objects. Now to properly deserialize such elements I need to call BsonClassMap.RegisterClassMap() for each of the derived types, otherwise deserializer complains about members not being mappable to base Component class. I'd like to use reflection to enumerate all Component-derived types and register class maps for them at the beginning, but there is a problem: it appears that there is no RegisterClassMap overload that takes a Type argument, only generic versions. Sticking a call to RegisterClassMap into static constructors don't help since their invocation order is not guaranteed. Any ideas how to achieve such run-time initialization without knowing the types beforehand?