Table of Contents

Interface ISavable

Namespace
Nucs.JsonSettings
Assembly
Nucs.JsonSettings.dll
public interface ISavable

Properties

FileName

The path for this ISaveable file, relative pathing allowed to current executing file.

string FileName { get; set; }

Property Value

string

Methods

Load()

Populate the data in this object from FileName.

void Load()

Load(string)

Populate the data in this object from given filename.

void Load(string filename)

Parameters

filename string

The path to the file inwhich to load, relative pathing allowed to current executing file.

LoadDefault(params object[])

Populate the data in this object from a newly created copy of GetType().

void LoadDefault(params object[] args)

Parameters

args object[]

Remarks

Triggers AfterLoad

LoadDefault<T>(params object[])

Populate the data in this object from a newly created copy of type T.

void LoadDefault<T>(params object[] args) where T : ISavable

Parameters

args object[]

Type Parameters

T

Remarks

Triggers AfterLoad

LoadJson(string, JsonSerializerSettings?)

Populate this object with given json.

void LoadJson(string json, JsonSerializerSettings? settings = null)

Parameters

json string

The json, specifying only the properties to change. Unspecified will be left untouched.

settings JsonSerializerSettings

Save()

Save the settings file to a predefined location and name FileName

void Save()

Save(string)

Save the settings file to a specific location!

void Save(string filename)

Parameters

filename string

ToJson(JsonSerializerSettings?, Type?, Formatting?)

Serializes this object to json.

string ToJson(JsonSerializerSettings? settings = null, Type? serializeAsType = null, Formatting? formatting = null)

Parameters

settings JsonSerializerSettings
serializeAsType Type
formatting Formatting?

The formatting to serialize JSON as. By default it'll take settings

Returns

string

Events

AfterDecrypt

Called after Decrypt.

event AfterDecryptHandler? AfterDecrypt

Event Type

AfterDecryptHandler

AfterDeserialize

Invoked after deserialization of this instance was successful.

event AfterDeserializeHandler? AfterDeserialize

Event Type

AfterDeserializeHandler

AfterEncrypt

After encryption successful.

event AfterEncryptHandler? AfterEncrypt

Event Type

AfterEncryptHandler

AfterLoad

Invoked at the end of the loading progress.

event AfterLoadHandler? AfterLoad

Event Type

AfterLoadHandler

AfterRepopulate

Invoked after every JSON populate, from a finally -- fires even when the populate threw halfway; successfulPopulate is true only when the populate ran to completion.

event AfterRepopulateHandler? AfterRepopulate

Event Type

AfterRepopulateHandler

AfterSave

Invoked after saving this object.

event AfterSaveHandler? AfterSave

Event Type

AfterSaveHandler

AfterSerialize

event AfterSerializeHandler? AfterSerialize

Event Type

AfterSerializeHandler

BeforeDeserialize

Invoked after file was read and decrypted successfully right before deserializing into an object.

event BeforeDeserializeHandler? BeforeDeserialize

Event Type

BeforeDeserializeHandler

BeforeLoad

Invoked after path has been resolved and before reading.
FileInfo can be modified now.

event BeforeLoadHandler? BeforeLoad

Event Type

BeforeLoadHandler

BeforeRepopulate

Invoked immediately before a JSON populate rewrites this instance -- on every populate: Load(), LoadDefault(params object[]), recovery reloads and direct LoadJson(string, JsonSerializerSettings?) calls alike. Handlers must not save until AfterRepopulate.

event BeforeRepopulateHandler? BeforeRepopulate

Event Type

BeforeRepopulateHandler

BeforeSave

Invoked before saving this object.

event BeforeSaveHandler? BeforeSave

Event Type

BeforeSaveHandler

BeforeSerialize

event BeforeSerializeHandler? BeforeSerialize

Event Type

BeforeSerializeHandler

Decrypt

Called during loading right after BeforeLoad to decrypt the readed bytes, if Encrypt is not implemented - no reason to perform decryption.

event DecryptHandler? Decrypt

Event Type

DecryptHandler

Encrypt

After serializing, encryption can be applied now.

event EncryptHandler? Encrypt

Event Type

EncryptHandler