Pip-Services-Commons-Dotnet
Static Public Member Functions | Static Private Member Functions | List of all members
PipServices3.Commons.Reflect.MethodReflector Class Reference

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. More...

Static Public Member Functions

static bool HasMethod (object obj, string name)
 Checks if object has a method with specified name. More...
 
static object InvokeMethod (object obj, string name, params object[] args)
 Invokes an object method by its name with specified parameters. More...
 
static IEnumerable< string > GetMethodNames (object obj)
 Gets names of all methods implemented in specified object. More...
 

Static Private Member Functions

static bool MatchMethod (MethodInfo method, string name)
 

Detailed Description

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.

var myObj = new MyObject();
var methods = MethodReflector.GetMethodNames();
MethodReflector.HasMethod(myObj, "myMethod");
MethodReflector.InvokeMethod(myObj, "myMethod", 123);

Member Function Documentation

◆ GetMethodNames()

static IEnumerable<string> PipServices3.Commons.Reflect.MethodReflector.GetMethodNames ( object  obj)
static

Gets names of all methods implemented in specified object.

Parameters
objan objec to introspect.
Returns
a list with method names.

◆ HasMethod()

static bool PipServices3.Commons.Reflect.MethodReflector.HasMethod ( object  obj,
string  name 
)
static

Checks if object has a method with specified name.

Parameters
objan object to introspect.
namea name of the method to check.
Returns
true if the object has the method and false if it doesn't.

◆ InvokeMethod()

static object PipServices3.Commons.Reflect.MethodReflector.InvokeMethod ( object  obj,
string  name,
params object []  args 
)
static

Invokes an object method by its name with specified parameters.

Parameters
objan object to invoke.
namea name of the method to invoke.
argsa list of method arguments.
Returns
the result of the method invocation or null if method returns void.

The documentation for this class was generated from the following file: