Appearance
CreateObjectFromDictionary Method
Definition
- Namespace:
JASE - Assembly:
JASE.ReflectionTools.dll
T CreateObjectFromDictionary(IDictionary<string, object> properties, bool suppressExceptions = null, bool publicOnly = null, bool allowNonPublicConstructor = null, bool jsonPropertyTranslation = null)
csharp
T CreateObjectFromDictionary(IDictionary<string, object> properties, bool suppressExceptions = null, bool publicOnly = null, bool allowNonPublicConstructor = null, bool jsonPropertyTranslation = null)Creates an instance of the specified type T and populates its properties from a dictionary of values.
Type parameters
| Name | Description |
|---|---|
T | The type of object to create and populate. |
Parameters
| Name | Description |
|---|---|
allowNonPublicConstructor | If true, allows instantiation using a non-public parameterless constructor. If false, only public constructors will be used. |
jsonPropertyTranslation | If true, supports mapping JSON property names (via JsonProperty attributes) to object properties. |
properties | A dictionary of property names and values to assign to the new object. |
publicOnly | If true, only public properties are considered for assignment. If false, both public and non-public instance properties are included. |
suppressExceptions | If true, unknown dictionary keys and missing source mappings are silently ignored. If false, an ArgumentException will be thrown when a dictionary key does not map to a property. |
Returns
A new instance of T with properties populated from the provided dictionary.