MethodReflector class

Helper class to perform method introspection and dynamic invocation.

This class has symmetric implementation across all languages supported by Pip.Services toolkit and used to support dynamic data processing.

Because all languages have different casing and case sensitivity rules, this MethodReflector treats all method names as case insensitive.

Example

var myObj = new MyObject();

var methods = MethodReflector.getMethodNames();
MethodReflector.hasMethod(myObj, "myMethod");
MethodReflector.invokeMethod(myObj, "myMethod", 123);

Constructors

MethodReflector()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Methods

getMethodNames(dynamic obj) → List<String>
Gets names of all methods implemented in specified object. [...]
hasMethod(dynamic obj, String name) → bool
  • Checks if object has a method with specified name..
      • obj an object to introspect.
      • name a name of the method to check.
    • Returns true if the object has the method and false if it doesn't.
  • invokeMethod(dynamic obj, String name, List args) → dynamic
  • Invokes an object method by its name with specified parameters.
      • obj an object to invoke.
      • name a name of the method to invoke.
      • args a list of method arguments.
    • Returns the result of the method invocation or null if method returns void.