-
Notifications
You must be signed in to change notification settings - Fork 15
Getting Started
If you haven't already, see Installing for how to install SUCC.
To work with SUCC data, you must create a DataFile
object. Each DataFile
corresponds to an actual file in storage.
using SUCC;
static class Program
{
static DataFile Config = new DataFile("ProgramConfig");
}
The Config
DataFile will correspond to a file called ProgramConfig.succ
in the default path. If the file doesn't exist already, it will be created.
You probably want to keep your DataFiles in static variables. They can be created with field initializers, as in the example above.
Once you have a DataFile, you use the Get
and Set
methods to load and save values from the file.
using SUCC;
static class Program
{
static DataFile Config = new DataFile("ProgramConfig");
static void Main()
{
Config.Set("example value", 1234);
int exampleValue = Config.Get<int>("example value");
}
}
The Set
there modifies the data labeled example value
in ProgramConfig.succ
. If that label doesn't exist, it will create it. After running that code, ProgramConfig.succ
will look like this:
example value: 1234
Then, the Get
will try to find data in the file labeled example value
. Since we just set the value, it will return 1234
.
In practice, you will most often use Get
with a defaultValue
, like so:
using SUCC;
static class Program
{
static DataFile Config = new DataFile("ProgramConfig");
static void Main()
{
int exampleValue = Config.Get("example value", 1234);
}
}
Here's how that works:
- if there's data labeled
example value
inProgramConfig.succ
, it will load that data and return it to you - if there isn't yet data labeled
example value
inProgramConfig.succ
, it will save1234
and return you1234
.
This is great because in one line of code you can both load a value from your config file and set a default value if it's missing from the file.
- Overview
- Installing
- Getting Started
- Advanced Usage
- File Logic
- Version Differences
- Contributing
- Projects Using SUCC