Thursday, November 16, 2006 6:11 PM
keremkusmezer
Great Project
Check out the following project from Codeplex.
http://www.codeplex.com/SourceControl/DownloadSourceCode.aspx?ProjectName=Dynamic&changeSetId=10442
Dynamic Reflection Library
The Dynamic Reflection Library is a small set of classes designed to greatly speed the use of .Net reflection to call constructors, member methods, property setters and getters including those with indexing arguments such as the Item (a.k.a. [] operator), and fields.
The libary uses Lightweight Code Generation (LCG) to synthesize the minimum wrapper code to allow fully type-safe calls to arbitrary methods in any class through type-safe delgates. If appropriate runtime rights are available, these methods can even access private fields, methods and properties.
All members may be bound by name, or MemberInfo with optional automatic type coercision of the delegate's arguments to the called-method's argmuents. It also will do type-signature mapping to allow you to match a desired delegate signature and method name to the best-fit method.
Also included in this library is a DynamicCompare class, that generates a very-high performance IComparer method against any class for one or more fields/properties (with ascending/descending support). This allows you to generate the delegate to pass to Sort at runtime against a user-defined sort criteria and get near native speed.