ReflectedObject

About
ReflectedObject Script

Reflects a target object, providing quick access by name to reading and writing its fields and properties, and calling its methods.

Script Version
0.1.0.0

Script Revision
5/24/2011

Description
The ReflectedObject is useful when you need to read and write, or call the methods of, a raw object instance. Create an instance of ReflectedObject on a target object to build a collection of that object's fields, properties, and methods which can then be quickly accessed by name. Fields and properties can be read or written to, and fields in particular can return values as bools, colors, floats, integers, strings, and vector3. Fields also have type-safe methods which will return true if the field can be returned as the desired type and will fill a reference parameter with the return value, and will return false if they cannot. In addition to reading and writing fields and properties, methods can be called and allow passing parameters and returning values.

You should create only one ReflectedObject per object instance and reuse it as long as possible. You should call Dispose on the ReflectedObject when you are finished with it in order to release the internal reference to the root object that was reflected.