pistacchio
pistacchio

Reputation: 58863

C# Library for easy dynamic reflection

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

Answers (7)

Mike Marynowski
Mike Marynowski

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

Trap
Trap

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

TheCodeMonk
TheCodeMonk

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

C. Ross
C. Ross

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

JP Alioto
JP Alioto

Reputation: 45117

There are some interesting ReflectionHelpers out there.

Upvotes: 1

Brian Rasmussen
Brian Rasmussen

Reputation: 116401

The MS unit test assembly has PrivateObject and PrivateType which make access to private instance/type members pretty straight forward.

Upvotes: 0

RameshVel
RameshVel

Reputation: 65857

there is a LinFu library available which can do lot other interesting stuffs than reflection... try it

Upvotes: 4

Related Questions