Reputation: 58863
Is there any library (like open source projects etc) that makes it easier to use complex reflection like creating objects or classes on the fly, inspecting instances etc?
Thanks
Upvotes: 6
Views: 3282
Reputation: 3429
Fastflect is a rather good library I've used that offers much simpler methods for calling and accessing members, as well as super simple delegate generation for just about anything you may need which increases performance significantly if you cache the delegate. It's documented fairly well which really helps. It's what I used before I wrote my own set of strongly typed generic delegate generation methods.
Upvotes: 0
Reputation: 12372
In my opinion I don't think reflection could get any easier to use than it is now. Almost all of the core functionality is wrapped up within the Type class. Just take your time to learn about how it works and you won't need another unnecessary layer on top of it.
Specifically, you can do 'complex things' as creating unitialized objects like this:
// Instantiates an uninitialized object of the specified type.
var newObject = (MyObject)FormatterServices.GetUninitializedObject( elementType );
Upvotes: 2
Reputation: 2089
If reflection is hard, then it might be possible that you don't have a full understanding of the basics of .Net. You might want to try a tutorial like this.
Upvotes: 1
Reputation: 31848
Reflection is by definition hard. It's a level of indirection placed over the whole object structure. I'm not really sure how you can make it easier, without limiting its power.
Upvotes: 1
Reputation: 116401
The MS unit test assembly has PrivateObject and PrivateType which make access to private instance/type members pretty straight forward.
Upvotes: 0