TypeReflector class

Helper class to perform object type introspection and object instantiation.

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 TypeReflector treats all type names as case insensitive.

See TypeDescriptor

Example

var descriptor = new TypeDescriptor("MyObject", "mylibrary");
Typeeflector.getTypeByDescriptor(descriptor);
var myObj = TypeReflector.createInstanceByDescriptor(descriptor);

TypeDescriptor.isPrimitive(myObject); 		// Result: false
TypeDescriptor.isPrimitive(123);				// Result: true

Constructors

TypeReflector()

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

createInstance(String name, String library, List args) → dynamic
  • Creates an instance of an object type specified by its name
    • and library where it is defined.
      • name an object type name.
      • library a library (module) where object type is defined.
      • args arguments for the object constructor.
    • Returns the created object instance.
    • See getType
    • See createInstanceByType
  • createInstanceByDescriptor(TypeDescriptor descriptor, List args) → dynamic
  • Creates an instance of an object type specified by type descriptor.
      • descriptor a type descriptor that points to an object type
      • args arguments for the object constructor.
    • Returns the created object instance.
    • See createInstance
    • See TypeDescriptor
  • createInstanceByType(Type type, List args) → dynamic
  • Creates an instance of an object type.
      • type an object type (factory function) to create.
      • args arguments for the object constructor.
    • Returns the created object instance.
  • getType(String name, [ String library = null ]) → Type
  • Gets object type by its name and library where it is defined.
      • name an object type name.
      • library a library where the type is defined
    • Returns the object type or null is the type wasn't found.
  • getTypeByDescriptor(TypeDescriptor descriptor) → Type
  • Gets object type by type descriptor.
      • descriptor a type descriptor that points to an object type
    • Returns the object type or null is the type wasn't found.
    • See getType
    • See TypeDescriptor
  • isPrimitive(dynamic value) → bool
  • Checks if value has primitive type.
    • Primitive types are: numbers, strings, booleans, date and time.
    • Complex (non-primitive types are): objects, maps and arrays
      • value a value to check
    • Returns true if the value has primitive type and false if value type is complex.
    • See TypeConverter.toTypeCode
    • See TypeCode