Menu

Usage

skyracer

This software is available as a package on NuGet.org.
.
Here's a few usage examples.

//create file instance with this minimum configuration
IFile file = new SmartFile("c:\path\file.ext", new Dictionary<string,string>());

//if you want to include settingsfile, derive from class Dictionary<string, string>
//and pass object as pDefaults
file = new SmartFile("c:\path\file.ext", new MyDefaultValues());
//this is usefull as you can create the keys as constants in the MyDefaultValues class

//add property like so
file.addProperty("key", "value");
//or so
file.addOrUpdate("key2", "newValue");

//you can write the settings anytime by calling
file.buildContent();
file.writeContentToFile();
//you can set the desired file mode by using the enums
file.setFileAccessMode(FileAccessMode.BINARY).writeContentToFile();
//chaining is possible because all void methods of IFile return the file object itself

//read and load contents from file and update settings dictionary
file.readLoadFileContent();
//mind that the keys in the file must match the keys in the default settings in order
//for the value from the file to be added or updated in the file object
//this only applies when the default value dictionary is not empty
//empty defaults mean that any key value pair can be loaded from file

//you can later change the default setting dictionary object by calling
file.setDefaults(new Dictionary<string,string>()); //or your own derived type
//then load the defaults as followes
file.loadDefaultValues();

//settings are available here
string s = file.Properties["key"];

//string represenation of settings
s = file.getStringView();
//if you prefer a different textformat call
s = file.setTextDataFormat(TextDataFormat.JSON).getStringView();