IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.StringSettings Class Reference
+ Inheritance diagram for IG.Lib.StringSettings:
+ Collaboration diagram for IG.Lib.StringSettings:

Public Member Functions

 StringSettings ()
 
override void Export (string filePath)
 Saves (serializes) the specified variable system to the specified JSON file. More...
 
override void Export (string filePath, bool append)
 Saves (serializes) the specified variable system to the specified JSON file. More...
 
override void Import (string filePath)
 Imports variables from the specified variable system in JSON format. More...
 
bool LockFileMutexCheckAbandoned ()
 Check whether the filesystem locking mutex (property LockFileMutex) has been abandoned, and returns true if it has been (otherwise, false is returned). More...
 
int AddSettingDirectories (params string[] directoryPaths)
 Adds the specified directory paths to the list of directories that are periodically checked for settings to be imported. More...
 
int RemoveSettingDirectories (params string[] directoryPaths)
 Removes the specified directory paths to the list of directories that are periodically checked for settings to be imported. More...
 
bool IsPeriodicImportCheckPerformed ()
 Returns a flag indicating whether the state of the current setting object is such that periodic checks and imports of settings form files are performed. More...
 
- Public Member Functions inherited from IG.Lib.StringVariableSystem
 StringVariableSystem ()
 Constructs a new system of string variables. More...
 
virtual string GetVariable (string varName)
 Returns value of the specified variable, or null if it is not defined. More...
 
virtual void SetVariable (string varName, string varValue)
 Sets the specified variable to the specified value. More...
 
virtual void AddNewVariable (string varName, string varValue)
 Adds a new variable of the specified name and with the specified value (which can be null). More...
 
virtual bool RemoveVariable (string varName)
 Removes a variable with the specified name from the current variable system, and returns a flag indicating whether variable was actually removed. More...
 
virtual int RemoveVariables (params string[] varNames)
 Removes all variables whose names are specified by the argument, and returns the number of variables that were actully been removed. More...
 
virtual bool UnSetVariable (string varName)
 Unsets the variable with the specified name on the current variable system, and returns a flag indicating whether variable was defined. More...
 
virtual bool IsVariableDefined (string varName)
 Returns true if the specified variable is defined, false otherwise. More...
 
virtual string[][] ToArray ()
 Returns array representation of variables that are currently defined on the system. More...
 
virtual void ImportVariables (string[][] variables)
 Imports variables defined in form of two dimensional array. More...
 
virtual void SetVariable (string varName, object varValue)
 Sets the specified variable to the specified value. More...
 
bool TryGetIntegerVariable (string varName, out int varTypedValue)
 Obtains a value of an integer-typed variable of the specified name, if such a variable is defined and its value can be interpreted as an integer. More...
 
int GetIntegerVariable (string varName)
 Returns the value of an integer-valued variable of the specified name. More...
 
bool TryGetDoubleVariable (string varName, out double varTypedValue)
 Obtains a value of a double-typed variable of the specified name, if such a variable is defined and its value can be interpreted as a number of type double. More...
 
double GetDoubleVariable (string varName)
 Returns the value of a double-valued variable of the specified name. More...
 
bool TryGetBooleanVariable (string varName, out bool varTypedValue)
 Obtains a value of a boolean-typed variable of the specified name, if such a variable is defined and its value can be interpreted as a boolean value. More...
 
bool GetBooleanVariable (string varName)
 Returns the value of a boolean-valued variable of the specified name. More...
 
bool GetFlag (string flagName)
 Returns value of the flag with the specified name. More...
 
void SetFlag (string flagName, bool flagValue)
 Sets the flag of the specified name to the specified value. More...
 
void PrintVariables ()
 Prints all variables (with their values) defined on the current object. More...
 

Static Public Member Functions

static void SaveJson (StringSettings settings, string filePath)
 Saves (serializes) the specified variable system to the specified JSON file. File is owerwritten if it exists. More...
 
static void SaveJson (StringSettings settings, string filePath, bool append)
 Saves (serializes) the specified variable system to the specified JSON file. If the file already exists, contents either overwrites the file or is appended at the end, dependent on the value of the append flag. More...
 
static void LoadJson (string filePath, ref StringSettings settingsRestored)
 Restores (deserializes) a vector from the specified file in JSON format. More...
 
static void ExportDto (StringSettingsDto settings, string filePath)
 Saves (serializes) the specified variable system DTO to the specified JSON file. More...
 
static void ExportDto (StringSettingsDto variables, string filePath, bool append)
 Saves (serializes) the specified variable system DTO to the specified JSON file. More...
 
static void ImportDto (string filePath, ref StringSettingsDto settings)
 Restores (deserializes) variable system DTO from the specified file in JSON format. More...
 
- Static Public Member Functions inherited from IG.Lib.StringVariableSystem
static void SaveJson (StringVariableSystem variableSystem, string filePath)
 Saves (serializes) the specified variable system to the specified JSON file. File is owerwritten if it exists. More...
 
static void SaveJson (StringVariableSystem variableSystem, string filePath, bool append)
 Saves (serializes) the specified variable system to the specified JSON file. If the file already exists, contents either overwrites the file or is appended at the end, dependent on the value of the append flag. More...
 
static void LoadJson (string filePath, ref StringVariableSystem variableSystemRestored)
 Restores (deserializes) a vector from the specified file in JSON format. More...
 
static void ExportDto (StringVariableSystemDto settings, string filePath)
 Saves (serializes) the specified variable system DTO to the specified JSON file. More...
 
static void ExportDto (StringVariableSystemDto variables, string filePath, bool append)
 Saves (serializes) the specified variable system DTO to the specified JSON file. More...
 
static void ImportDto (string filePath, ref StringVariableSystemDto settings)
 Restores (deserializes) variable system DTO from the specified file in JSON format. More...
 
static void TestMisc ()
 Miscellaneous tests. More...
 

Public Attributes

const string DefaultLockFileMutexName = "Global\\IG.Lib.Utils.MutexSettingsDefault.R2D2_by_Igor_Gresovnik"
 Default name of the mutex for system-wide locking of files used by the current class. More...
 
const string DefaultImportingFilename = "settingsglobal.json"
 Default name of the file containing settings to be imported. More...
 
const string DefaultMsgImportOnceFilename = "importsettings.msg"
 Default name of the message file instructing object of this class to import the settings file once and then delete the message. More...
 
const string DefaultMsgImportContinuoslyFilename = "importsettingscontinuously.msg"
 Default name of the message file instructing object of this class to continuously import the settings file without deleting the message. More...
 
const double DefaultImportCheckPeriodSeconds = 1.0421
 Default period for checking for settings to be imported (ind importing them, if applicable). More...
 
const double MinimalImportCheckPeriodSeconds = 0.01
 Minimal period for checking for settings to be imported (ind importing them, if applicable). More...
 

Protected Member Functions

bool CheckAndImport (string directoryPath)
 Check the directory with the specified path for instructions to import the settings file, imports the settings file if instructed so and if the settings file exists, and eventualy removes the message instructing a single import. More...
 
void ImportPeriodically ()
 Periodically checks the designated directories for settings to be imported, and imports them if availeble. More...
 
void StartImportingThreadIfNotRunning ()
 Starts the thread that periodically checks for settings to be imported and imports them. More...
 
void StopImportingThreadIfRunning ()
 Stops the thread that periodically checks for settings to be imported and imports them. More...
 
void OnChangedImportingStatus ()
 Method that is called every time the state of variables that influence how periodic importing is done, is changed. More...
 

Protected Attributes

string _lockFileMutexName = DefaultLockFileMutexName
 
Mutex _lockFileMutex
 
string _msgImportOnceFilename = DefaultMsgImportOnceFilename
 
string _msgImportContinuouslyFilename = DefaultMsgImportContinuoslyFilename
 
string _importingFilename = DefaultImportingFilename
 
bool _doImportPeriodically = true
 
double _importCheckPeriodSeconds = DefaultImportCheckPeriodSeconds
 
Thread _importingThread
 
- Protected Attributes inherited from IG.Lib.StringVariableSystem
SortedList< string, string > _variables = new SortedList<string, string>()
 

Properties

string LockFileMutexName [get, set]
 Name of the mutex for system-wide locking of files used by the current class. More...
 
virtual Mutex LockFileMutex [get, set]
 Mutex for system-wide exclusive locks for file system operations related to the current class. More...
 
string MsgImportOnceFilename [get, set]
 Name of the message file instructing object of this class to import the settings file once and then delete the message. More...
 
string MsgImportContinuoslyFilename [get, set]
 Name of the message file instructing object of this class to continuously import the settings file without deleting the message. More...
 
string ImportingFilename [get, set]
 Name of the message file instructing object of this class to continuously import the settings file without deleting the message. More...
 
bool DoImportPeriodically [get, set]
 Flag indicating whether the current object should periodically check the designated directories for settings to be imported, and import them. More...
 
double ImportCheckPeriodSeconds [get, set]
 Period for checking for settings to be imported (ind importing them, if applicable). More...
 
List< string > SettingDirectories [get]
 
- Properties inherited from IG.Lib.StringVariableSystem
object Lock [get]
 This object's central lock object to be used by other object. More...
 
bool SetNullOnImport [get, set]
 Flag indicating whether null variable values are also set when importing variable values. If false then, if some imported variable has null value, this variable will not be set on the current system of variables. This means that the value of eventually existent variable will remain unchanged if variables are imported from another system where this variable is defined but has null value. More...
 
virtual SortedList< string,
string > 
Variables [get]
 
virtual string this[string varName] [get, set]
 Gets or sets value of the specified variable. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Attributes

List< string > _settingDirectories
 

Constructor & Destructor Documentation

IG.Lib.StringSettings.StringSettings ( )
inline

Member Function Documentation

override void IG.Lib.StringSettings.Export ( string  filePath)
inlinevirtual

Saves (serializes) the specified variable system to the specified JSON file.

If the file already exists, contents overwrite the file.

Parameters
filePathPath to the file in variables and properties of the system are saved.

Reimplemented from IG.Lib.StringVariableSystem.

override void IG.Lib.StringSettings.Export ( string  filePath,
bool  append 
)
inlinevirtual

Saves (serializes) the specified variable system to the specified JSON file.

If the file already exists, contents either overwrite the file or are appended at the end, dependent on the value of the append flag.

Parameters
filePathPath to the file in variables and properties of the system are saved.
appendSpecifies whether serialized data is appended at the end of the file in the case that the file already exists.

Reimplemented from IG.Lib.StringVariableSystem.

References IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFrom().

override void IG.Lib.StringSettings.Import ( string  filePath)
inlinevirtual

Imports variables from the specified variable system in JSON format.

Parameters
filePathFile from which object is restored.

Reimplemented from IG.Lib.StringVariableSystem.

static void IG.Lib.StringSettings.SaveJson ( StringSettings  settings,
string  filePath 
)
inlinestatic

Saves (serializes) the specified variable system to the specified JSON file. File is owerwritten if it exists.

Parameters
settingsObject that is saved to a file.
filePathPath to the file in which object is is saved.
static void IG.Lib.StringSettings.SaveJson ( StringSettings  settings,
string  filePath,
bool  append 
)
inlinestatic

Saves (serializes) the specified variable system to the specified JSON file. If the file already exists, contents either overwrites the file or is appended at the end, dependent on the value of the append flag.

Parameters
settingsObject that is saved to a file.
filePathPath to the file into which object is saved.
appendSpecifies whether serialized data is appended at the end of the file in the case that the file already exists.

References IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFrom().

static void IG.Lib.StringSettings.LoadJson ( string  filePath,
ref StringSettings  settingsRestored 
)
inlinestatic

Restores (deserializes) a vector from the specified file in JSON format.

Parameters
filePathFile from which object is restored.
settingsRestoredObject that is restored by deserialization.

References IG.Lib.SerializationDtoBase< Type, BaseType >.CopyTo().

static void IG.Lib.StringSettings.ExportDto ( StringSettingsDto  settings,
string  filePath 
)
inlinestatic

Saves (serializes) the specified variable system DTO to the specified JSON file.

If the file already exists, contents overwrite the file.

Parameters
settingsVariable system DTO that is saved to a file.
filePathPath to the file into which variables (and settings and other stuff) are saved.
static void IG.Lib.StringSettings.ExportDto ( StringSettingsDto  variables,
string  filePath,
bool  append 
)
inlinestatic

Saves (serializes) the specified variable system DTO to the specified JSON file.

If the file already exists, contents either overwrite the file or are appended at the end, dependent on the value of the append flag.

Parameters
variablesVariable system DTO that is saved to a file.
filePathPath to the file into which variables (and settings and other stuff) are saved.
appendSpecifies whether serialized data is appended at the end of the file in the case that the file already exists.
static void IG.Lib.StringSettings.ImportDto ( string  filePath,
ref StringSettingsDto  settings 
)
inlinestatic

Restores (deserializes) variable system DTO from the specified file in JSON format.

The restored DTO can be used e.g. to import variables to a variable system.

Parameters
filePathFile from which object is restored.
settingsVariable system DTO that is restored by deserialization.
bool IG.Lib.StringSettings.LockFileMutexCheckAbandoned ( )
inline

Check whether the filesystem locking mutex (property LockFileMutex) has been abandoned, and returns true if it has been (otherwise, false is returned).

After the call, mutex is no longer in abandoned state (WaitOne() will not throw an exception) if it has been before the call.

Call does not block.

Returns
true if mutex has been abandoned, false otherwise.

References IG.Lib.Util.MutexCheckAbandoned().

int IG.Lib.StringSettings.AddSettingDirectories ( params string[]  directoryPaths)
inline

Adds the specified directory paths to the list of directories that are periodically checked for settings to be imported.

Parameters
directoryPathsPaths to be added to the list, can be relative or absolute.
Returns
Number of directories that were actually added to the list.

References IG.Lib.UtilSystem.StandardizeDirectoryPath().

int IG.Lib.StringSettings.RemoveSettingDirectories ( params string[]  directoryPaths)
inline

Removes the specified directory paths to the list of directories that are periodically checked for settings to be imported.

Parameters
directoryPathsPaths to be added to the list, can be relative or absolute.
Returns
Number of directories that were actually removed from the list.

References IG.Lib.UtilSystem.StandardizeDirectoryPath().

bool IG.Lib.StringSettings.CheckAndImport ( string  directoryPath)
inlineprotected

Check the directory with the specified path for instructions to import the settings file, imports the settings file if instructed so and if the settings file exists, and eventualy removes the message instructing a single import.

Returns true if settings were imported, false otherwise.

Parameters
directoryPathPath to the directory where settings are checked.
void IG.Lib.StringSettings.ImportPeriodically ( )
inlineprotected

Periodically checks the designated directories for settings to be imported, and imports them if availeble.

Check and import is performed by the CheckAndImport method.

References IG.Lib.Util.SleepSeconds().

bool IG.Lib.StringSettings.IsPeriodicImportCheckPerformed ( )
inline

Returns a flag indicating whether the state of the current setting object is such that periodic checks and imports of settings form files are performed.

void IG.Lib.StringSettings.StartImportingThreadIfNotRunning ( )
inlineprotected

Starts the thread that periodically checks for settings to be imported and imports them.

void IG.Lib.StringSettings.StopImportingThreadIfRunning ( )
inlineprotected

Stops the thread that periodically checks for settings to be imported and imports them.

void IG.Lib.StringSettings.OnChangedImportingStatus ( )
inlineprotected

Method that is called every time the state of variables that influence how periodic importing is done, is changed.

This method checks whether periodic checking should be performed or not. If it should be performed, then it starts the thread that does it, if it is not already running. If it sould not be performed, then it stops that tread if it is running.

Member Data Documentation

const string IG.Lib.StringSettings.DefaultLockFileMutexName = "Global\\IG.Lib.Utils.MutexSettingsDefault.R2D2_by_Igor_Gresovnik"

Default name of the mutex for system-wide locking of files used by the current class.

const string IG.Lib.StringSettings.DefaultImportingFilename = "settingsglobal.json"

Default name of the file containing settings to be imported.

const string IG.Lib.StringSettings.DefaultMsgImportOnceFilename = "importsettings.msg"

Default name of the message file instructing object of this class to import the settings file once and then delete the message.

const string IG.Lib.StringSettings.DefaultMsgImportContinuoslyFilename = "importsettingscontinuously.msg"

Default name of the message file instructing object of this class to continuously import the settings file without deleting the message.

const double IG.Lib.StringSettings.DefaultImportCheckPeriodSeconds = 1.0421

Default period for checking for settings to be imported (ind importing them, if applicable).

const double IG.Lib.StringSettings.MinimalImportCheckPeriodSeconds = 0.01

Minimal period for checking for settings to be imported (ind importing them, if applicable).

string IG.Lib.StringSettings._lockFileMutexName = DefaultLockFileMutexName
protected
Mutex IG.Lib.StringSettings._lockFileMutex
protected
string IG.Lib.StringSettings._msgImportOnceFilename = DefaultMsgImportOnceFilename
protected
string IG.Lib.StringSettings._msgImportContinuouslyFilename = DefaultMsgImportContinuoslyFilename
protected
string IG.Lib.StringSettings._importingFilename = DefaultImportingFilename
protected
bool IG.Lib.StringSettings._doImportPeriodically = true
protected
double IG.Lib.StringSettings._importCheckPeriodSeconds = DefaultImportCheckPeriodSeconds
protected
List<string> IG.Lib.StringSettings._settingDirectories
private
Thread IG.Lib.StringSettings._importingThread
protected

Property Documentation

string IG.Lib.StringSettings.LockFileMutexName
getset

Name of the mutex for system-wide locking of files used by the current class.

virtual Mutex IG.Lib.StringSettings.LockFileMutex
getsetprotected

Mutex for system-wide exclusive locks for file system operations related to the current class.

string IG.Lib.StringSettings.MsgImportOnceFilename
getset

Name of the message file instructing object of this class to import the settings file once and then delete the message.

string IG.Lib.StringSettings.MsgImportContinuoslyFilename
getset

Name of the message file instructing object of this class to continuously import the settings file without deleting the message.

string IG.Lib.StringSettings.ImportingFilename
getset

Name of the message file instructing object of this class to continuously import the settings file without deleting the message.

bool IG.Lib.StringSettings.DoImportPeriodically
getsetprotected

Flag indicating whether the current object should periodically check the designated directories for settings to be imported, and import them.

Directories that are checked for settings are set by the AddSettingDirectories and RemoveSettingDirectories methods. Time periods are specified by the ImportCheckPeriodSeconds property.

Checking and importing settings is performed by the CheckAndImport method.

double IG.Lib.StringSettings.ImportCheckPeriodSeconds
getset

Period for checking for settings to be imported (ind importing them, if applicable).

List<string> IG.Lib.StringSettings.SettingDirectories
getprotected

The documentation for this class was generated from the following file: