Skip to content

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 ​

NameDescription
TThe type of object to create and populate.

Parameters ​

NameDescription
allowNonPublicConstructorIf true, allows instantiation using a non-public parameterless constructor. If false, only public constructors will be used.
jsonPropertyTranslationIf true, supports mapping JSON property names (via JsonProperty attributes) to object properties.
propertiesA dictionary of property names and values to assign to the new object.
publicOnlyIf true, only public properties are considered for assignment. If false, both public and non-public instance properties are included.
suppressExceptionsIf 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.