added AllClassMaps static method to BsonClassMap #129

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@alexjamesbrown

Allows us to get all class maps out of BsonClassMap.

@craiggwilson
Collaborator

Good idea Alex. We'll discuss pulling this in.

@alexjamesbrown

Thanks :)

@alexjamesbrown

just wondering if there was any update on this?

@craiggwilson
Collaborator

Alex, there is an IsClassMapRegistered method? Is this suitable for what you need, or is there another reason you would like to have a list.

@alexjamesbrown

There is, and while that works, it doesn't allow me to get all mapped types, without iterating over my types, and running .IsClassMapRegistered on each one...

@Cyberlane

@craiggwilson I could do with this feature from @alexjamesbrown as well, as I need to call the "Reset" method on each of them. Without a stored list, this does not perform well at all...

@alexjamesbrown

It would really make life a lot easier for people...

@Cyberlane

As a temp solution, I am using the following...

typeof(BsonClassMap).GetField("__classMaps", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)
@alexjamesbrown

Yeah, but again, not ideal
This pull request literally just returns __classMaps.Values as a public IEnumerable<BsonClassMap>
It's even covered by unit tests!

Would make the lives of people wanting this functionality so much easier.

@Cyberlane

Fully agree with you that the temp solution I am using is not ideal, and I would much rather have your pull request and a couple other bits from the Experiment branch, as I have to do a lot of dirty hacks to get what I need currently.

@craiggwilson
Collaborator

in code review... track at https://jira.mongodb.org/browse/CSHARP-628.

I renamed the method to GetRegisteredClassMaps().

@craiggwilson
Collaborator

pushed to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment