PropertyReflector class

Helper class to perform property introspection and dynamic reading and writing.

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 PropertyReflector treats all property names as case insensitive.

Example

var myObj = new MyObject();

var properties = PropertyReflector.getPropertyNames();
PropertyReflector.hasProperty(myObj, "myProperty");
var value = PropertyReflector.getProperty(myObj, "myProperty");
PropertyReflector.setProperty(myObj, "myProperty", 123);

Constructors

PropertyReflector()

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

getProperties(dynamic obj) → Map<String, dynamic>
  • Get values of all properties in specified object and returns them as a map.
      • obj an object to get properties from.
    • Returns a map, containing the names of the object's properties and their values.
  • getProperty(dynamic obj, String name) → dynamic
  • Gets value of object property specified by its name.
      • obj an object to read property from.
      • name a name of the property to get.
    • Returns the property value or null if property doesn't exist or introspection failed.
  • getPropertyNames(dynamic obj) → List<String>
    Gets names of all properties implemented in specified object. [...]
    hasProperty(dynamic obj, String name) → bool
  • Checks if object has a property with specified name..
      • obj an object to introspect.
      • name a name of the property to check.
    • Returns true if the object has the property and false if it doesn't.
  • setProperties(dynamic obj, Map<String, dynamic> values) → void
  • Sets values of some (all) object properties.
    • If some properties do not exist or introspection fails
    • they are just silently skipped and no errors thrown.
      • obj an object to write properties to.
      • values a map, containing property names and their values.
    • See [setProperty]
  • setProperty(dynamic obj String name, dynamic value) → void
    Sets value of object property specified by its name. [...]