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

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

Static Public Member Functions

static void SetProperty (object obj, string name, object value)
 Recursively sets value of object and its subobjects property specified by its name. More...
 
static void SetProperties (object obj, IDictionary< string, object > values)
 Recursively sets values of some (all) object and its subobjects properties. More...
 
static void CopyProperties (object dest, object src)
 Copies content of one object to another object by recursively reading all properties from source object and then recursively writing them to destination object. More...
 

Static Private Member Functions

static object CreateProperty (object obj, string[] names, int nameIndex)
 
static void PerformSetProperty (object obj, string[] names, int nameIndex, object value)
 

Detailed Description

Helper class to perform property introspection and dynamic writing.

It is similar to ObjectWriter but writes properties recursively through the entire object graph.Nested property names are defined using dot notation as "object.subobject.property"

See PropertyReflector, ObjectWriter

Member Function Documentation

◆ CopyProperties()

static void PipServices3.Commons.Reflect.RecursiveObjectWriter.CopyProperties ( object  dest,
object  src 
)
static

Copies content of one object to another object by recursively reading all properties from source object and then recursively writing them to destination object.

Parameters
desta destination object to write properties to.
srca source object to read properties from

◆ SetProperties()

static void PipServices3.Commons.Reflect.RecursiveObjectWriter.SetProperties ( object  obj,
IDictionary< string, object >  values 
)
static

Recursively sets values of some (all) object and its subobjects properties.

The object can be a user defined object, map or array.Property values correspondently are object properties, map key-pairs or array elements with their indexes.

If some properties do not exist or introspection fails they are just silently skipped and no errors thrown.

Parameters
objan object to write properties to.
valuesa map, containing property names and their values.

See SetProperty(object, string, object)

◆ SetProperty()

static void PipServices3.Commons.Reflect.RecursiveObjectWriter.SetProperty ( object  obj,
string  name,
object  value 
)
static

Recursively sets value of object and its subobjects property specified by its name.

The object can be a user defined object, map or array.The property name correspondently must be object property, map key or array index. If the property does not exist or introspection fails this method doesn't do anything and doesn't any throw errors.

Parameters
objan object to write property to.
namea name of the property to set.
valuea new value for the property to set.

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