Skip to content

Custom instance factory

You may wish to provide a custom object instance factory. The example below shows how to achieve this.

Note

In this example we are just using what the default configuration uses: Activator.CreateInstance

var theObject = new Dictionary<string, object>
{
    ["AValue"] = 12
}
.ToObject<MyObject>(c => c
    .WithInstanceFactory(Activator.CreateInstance));

// This will result in an instance of MyObject with AValue set to 12