1 | /**
|
2 | * Helper class to perform method introspection and dynamic invocation.
|
3 | *
|
4 | * This class has symmetric implementation across all languages supported
|
5 | * by Pip.Services toolkit and used to support dynamic data processing.
|
6 | *
|
7 | * Because all languages have different casing and case sensitivity rules,
|
8 | * this MethodReflector treats all method names as case insensitive.
|
9 | *
|
10 | * ### Example ###
|
11 | *
|
12 | * let myObj = new MyObject();
|
13 | *
|
14 | * let methods = MethodReflector.getMethodNames();
|
15 | * MethodReflector.hasMethod(myObj, "myMethod");
|
16 | * MethodReflector.invokeMethod(myObj, "myMethod", 123);
|
17 | */
|
18 | export declare class MethodReflector {
|
19 | private static matchMethod;
|
20 | /**
|
21 | * Checks if object has a method with specified name..
|
22 | *
|
23 | * @param obj an object to introspect.
|
24 | * @param name a name of the method to check.
|
25 | * @returns true if the object has the method and false if it doesn't.
|
26 | */
|
27 | static hasMethod(obj: any, name: string): boolean;
|
28 | /**
|
29 | * Invokes an object method by its name with specified parameters.
|
30 | *
|
31 | * @param obj an object to invoke.
|
32 | * @param name a name of the method to invoke.
|
33 | * @param args a list of method arguments.
|
34 | * @returns the result of the method invocation or null if method returns void.
|
35 | */
|
36 | static invokeMethod(obj: any, name: string, ...args: any[]): any;
|
37 | /**
|
38 | * Gets names of all methods implemented in specified object.
|
39 | *
|
40 | * @param obj an objec to introspect.
|
41 | * @returns a list with method names.
|
42 | */
|
43 | static getMethodNames(obj: any): string[];
|
44 | }
|