Show / Hide Table of Contents

Method JSettings.Load


Overload

Loads a JSON file and deserializes to an object of type T, or creates a new object of type T.

protected static T Load<T>(string file, bool useDefault = false, bool? useDefaultOnError = true) where T : JSettings
Parameters
file  (string)

Full path of .json file. If null, does not load and will not save.

useDefault  (bool)

Use default settings, don't load from file. Delete file if exists.

useDefaultOnError  (bool?)

What to do if failed to load or parse the file: true (default) - backup (rename) the file and use default settings; false - throw exception (for example JsonException if invalid JSON); null - show dialog with options to exit or use default settings.

Returns
T

An object of type T. Just creates a new object if the file does not exist or failed to load or parse (invalid JSON) or useDefaulttrue.

Exceptions
ArgumentException

Not full path.

NotSupportedException

Field type not supported by JsonSerializer.

Type Parameters
T