Header menu logo DynamicObj

DynamicObj Type

Constructors

Constructor Description

DynamicObj()

Full Usage: DynamicObj()

Returns: DynamicObj
Returns: DynamicObj

Instance members

Instance member Description

this.DeepCopyProperties

Full Usage: this.DeepCopyProperties

Returns: obj

Recursively deep copy a `DynamicObj` instance (or derived class) with **all** (static and dynamic) properties. Reinstantiation - and therefore prevention of reference equality - is possible for `DynamicObj`, `array|list|ResizeArray`, and classes implementing `System.Icloneable` On the deep copy, as many properties as possible are re-instantiated as new objects, meaning the copy has as little reference equal properties as possible. The nature of DynamicObj however means that it is impossible to reliably deep copy all properties, as their type is not known on runtime and the contructors of the types are not known. The following cases are handled (in this precedence): - Basic F# types (int, float, bool, string, char, byte, sbyte, int16, uint16, int32, uint32, int64, uint64, single, decimal) - array, list, ResizeArray: These collections of DynamicObj are copied as a new collection with recursively deep copied elements. - System.ICloneable: If the property implements ICloneable, the Clone() method is called on the property. - DynamicObj (and derived classes): properties that are themselves DynamicObj instances are deep copied recursively. if a derived class has static properties (e.g. instance properties), these will be copied as dynamic properties on the new instance. Note on Classes that inherit from DynamicObj: Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement ICloneable. The deep coopied instances will be cast to DynamicObj with static/instance properties AND dynamic properties all set as dynamic properties. It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties, and then passing them to the class constructor if needed.

Returns: obj

this.DeepCopyPropertiesTo

Full Usage: this.DeepCopyPropertiesTo

Parameters:
    target : 'a - The target object to copy dynamic members to
    ?overWrite : bool - Whether existing properties on the target object will be overwritten

Recursively deep copies **all** (static and dynamic) properties to a **target** `DynamicObj` instance (or derived class). Reinstantiation - and therefore prevention of reference equality - is possible for `DynamicObj`, `array|list|ResizeArray`, and classes implementing `System.Icloneable` As many properties as possible are re-instantiated as new objects, meaning the copy has as little reference equal properties as possible. The nature of DynamicObj however means that it is impossible to reliably deep copy all properties, as their type is not known on runtime and the contructors of the types are not known. The following cases are handled (in this precedence): - Basic F# types (int, float, bool, string, char, byte, sbyte, int16, uint16, int32, uint32, int64, uint64, single, decimal) - array, list, ResizeArray: These collections of DynamicObj are copied as a new collection with recursively deep copied elements. - System.ICloneable: If the property implements ICloneable, the Clone() method is called on the property. - DynamicObj (and derived classes): properties that are themselves DynamicObj instances are deep copied recursively. if a derived class has static properties (e.g. instance properties), these will be copied as dynamic properties on the new instance. Note on Classes that inherit from DynamicObj: Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement ICloneable. The deep coopied instances will be cast to DynamicObj with static/instance properties AND dynamic properties all set as dynamic properties. It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties, and then passing them to the class constructor if needed.

target : 'a

The target object to copy dynamic members to

?overWrite : bool

Whether existing properties on the target object will be overwritten

this.GetProperties

Full Usage: this.GetProperties

Parameters:
    includeInstanceProperties : bool - whether to include instance properties (= 'static' properties on the class)

Returns: KeyValuePair<string, obj> seq

Returns a sequence of all dynamic properties as a key value pair of the property names and the boxed property values. When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.

includeInstanceProperties : bool

whether to include instance properties (= 'static' properties on the class)

Returns: KeyValuePair<string, obj> seq

this.GetPropertyHelpers

Full Usage: this.GetPropertyHelpers

Parameters:
    includeInstanceProperties : bool - whether to include instance properties (= 'static' properties on the class)

Returns: PropertyHelper seq

Returns PropertyHelpers for all dynamic properties of the DynamicObj. When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.

includeInstanceProperties : bool

whether to include instance properties (= 'static' properties on the class)

Returns: PropertyHelper seq

this.GetPropertyNames

Full Usage: this.GetPropertyNames

Parameters:
    includeInstanceProperties : bool -

Returns: string seq

Returns a sequence of all dynamic property names. When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.

includeInstanceProperties : bool

Returns: string seq

this.GetPropertyValue

Full Usage: this.GetPropertyValue

Parameters:
    propertyName : string - the name of the property to get

Returns: obj

Returns the boxed property value of the dynamic (or static) property with the given name.

propertyName : string

the name of the property to get

Returns: obj
MissingMemberException Thrown if no dynamic or static property with the given name exists

this.Properties

Full Usage: this.Properties

A dictionary of dynamic boxed properties

this.RemoveProperty

Full Usage: this.RemoveProperty

Parameters:
    propertyName : string - the name of the property to remove

Returns: bool

Removes any dynamic property with the given name from the input DynamicObj. If the property is static and mutable, it will be set to null. Static immutable properties cannot be removed.

propertyName : string

the name of the property to remove

Returns: bool
MemberAccessException Thrown if the dynamic property does not exist

this.SetProperty

Full Usage: this.SetProperty

Parameters:
    propertyName : string - the name of the property to set
    propertyValue : obj - the value of the property to set

Sets the dynamic (or static) property value with the given name, creating a new dynamic property if none exists.

propertyName : string

the name of the property to set

propertyValue : obj

the value of the property to set

this.ShallowCopyDynamicProperties

Full Usage: this.ShallowCopyDynamicProperties

Returns: DynamicObj

Copies all dynamic properties to a new `DynamicObj` instance without trying to prevent reference equality. Note that this function does not attempt to do any deep copying. The dynamic properties of the source will be copied as references to the target. If any of those properties are mutable or themselves DynamicObj instances, changes to the properties on the source will be reflected in the target.

Returns: DynamicObj

this.ShallowCopyDynamicPropertiesTo

Full Usage: this.ShallowCopyDynamicPropertiesTo

Parameters:
    target : 'a - The target object to copy dynamic members to
    ?overWrite : bool - Whether existing properties on the target object will be overwritten

Copies all dynamic properties to a target `DynamicObj` instance without trying to prevent reference equality. Note that this function does not attempt to do any deep copying. The dynamic properties of the source will be copied as references to the target. If any of those properties are mutable or themselves DynamicObj instances, changes to the properties on the source will be reflected in the target. If overWrite is set to true, existing properties on the target object will be overwritten.

target : 'a

The target object to copy dynamic members to

?overWrite : bool

Whether existing properties on the target object will be overwritten

this.TryGetDynamicPropertyHelper

Full Usage: this.TryGetDynamicPropertyHelper

Parameters:
    propertyName : string - The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

Returns Some(PropertyHelper) if a dynamic property with the given name exists, otherwise None.

propertyName : string

The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

this.TryGetPropertyHelper

Full Usage: this.TryGetPropertyHelper

Parameters:
    propertyName : string - The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

Returns Some(PropertyHelper) if a property (static or dynamic) with the given name exists, otherwise None.

propertyName : string

The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

this.TryGetPropertyValue

Full Usage: this.TryGetPropertyValue

Parameters:
    propertyName : string

Returns: obj option

Returns Some(boxed property value) if a dynamic (or static) property with the given name exists, otherwise None.

propertyName : string
Returns: obj option

this.TryGetStaticPropertyHelper

Full Usage: this.TryGetStaticPropertyHelper

Parameters:
    propertyName : string - The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

Returns Some(PropertyHelper) if a static property with the given name exists, otherwise None.

propertyName : string

The name of the property to get the PropertyHelper for

Returns: PropertyHelper option

this.TryGetTypedPropertyValue

Full Usage: this.TryGetTypedPropertyValue

Parameters:
    propertyName : string - the name of the property to get

Returns: 'TPropertyValue option

Returns Some('TPropertyValue) when a dynamic (or static) property with the given name and type exists, otherwise None. This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

propertyName : string

the name of the property to get

Returns: 'TPropertyValue option

Static members

Static member Description

lookup ? name

Full Usage: lookup ? name

Parameters:
    lookup : 'a
    name : string

Returns: obj

Operator to access a property by name This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

lookup : 'a
name : string
Returns: obj

(?<-) (lookup, name, value)

Full Usage: (?<-) (lookup, name, value)

Parameters:
    lookup : 'a
    name : string
    value : 'v

Operator to set a property value This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

This method is not Fable-compatible and can therefore not be used in code that will be transpiled.

lookup : 'a
name : string
value : 'v

DynamicObj.ofDict dynamicProperties

Full Usage: DynamicObj.ofDict dynamicProperties

Parameters:
    dynamicProperties : Dictionary<string, obj> - The dictionary with the dynamic properties

Returns: DynamicObj

Creates a new DynamicObj from a Dictionary containing dynamic properties.

dynamicProperties : Dictionary<string, obj>

The dictionary with the dynamic properties

Returns: DynamicObj

Type something to start searching.