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
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
filenamestringThe 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
argsobject[]
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
argsobject[]
Type Parameters
T
Remarks
Triggers AfterLoad
LoadJson(string, JsonSerializerSettings?)
Populate this object with given json.
void LoadJson(string json, JsonSerializerSettings? settings = null)
Parameters
jsonstringThe json, specifying only the properties to change. Unspecified will be left untouched.
settingsJsonSerializerSettings
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
filenamestring
ToJson(JsonSerializerSettings?, Type?, Formatting?)
Serializes this object to json.
string ToJson(JsonSerializerSettings? settings = null, Type? serializeAsType = null, Formatting? formatting = null)
Parameters
settingsJsonSerializerSettingsserializeAsTypeTypeformattingFormatting?The formatting to serialize JSON as. By default it'll take
settings
Returns
Events
AfterDecrypt
Called after Decrypt.
event AfterDecryptHandler? AfterDecrypt
Event Type
AfterDeserialize
Invoked after deserialization of this instance was successful.
event AfterDeserializeHandler? AfterDeserialize
Event Type
AfterEncrypt
After encryption successful.
event AfterEncryptHandler? AfterEncrypt
Event Type
AfterLoad
Invoked at the end of the loading progress.
event AfterLoadHandler? AfterLoad
Event Type
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
AfterSave
Invoked after saving this object.
event AfterSaveHandler? AfterSave
Event Type
AfterSerialize
event AfterSerializeHandler? AfterSerialize
Event Type
BeforeDeserialize
Invoked after file was read and decrypted successfully right before deserializing into an object.
event BeforeDeserializeHandler? BeforeDeserialize
Event Type
BeforeLoad
Invoked after path has been resolved and before reading.
FileInfo can be modified now.
event BeforeLoadHandler? BeforeLoad
Event Type
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
BeforeSave
Invoked before saving this object.
event BeforeSaveHandler? BeforeSave
Event Type
BeforeSerialize
event BeforeSerializeHandler? BeforeSerialize
Event Type
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
Encrypt
After serializing, encryption can be applied now.
event EncryptHandler? Encrypt