-
Notifications
You must be signed in to change notification settings - Fork 15
Custom Complex Type Rules
Jimmy Cushnie edited this page Mar 10, 2019
·
3 revisions
By default, Complex Types are saved according to the following rules: all public, non-static, read-and-write-enabled fields and properties of a type are saved and loaded. However, sometimes you don't want to save a public member, and sometimes you do want to save a private member. You can make this happen with SUCC.DontSaveAttribute
and SUCC.DoSaveAttribute
.
public class Cat
{
public string Name { get; private set; }
public float Fuzziness;
public float Mass;
}
Say I have a Cat
with Name = Wiggles
, Fuzziness = 3.5
, and Mass = 30
. By default it will be saved like this:
cat:
Fuzziness: 3.5
Mass: 30
However, I do want to save Name
, and I don't want to save Mass
. I can do so like this:
using SUCC;
public class Cat
{
[DoSave] public string Name { get; private set; }
public float Fuzziness;
[DontSave] public float Mass;
}
The Cat
will now be saved like so:
cat:
Name: Wiggles
Fuzziness: 3.5
Currently, you can only control which fields and properties are saved in types that you control.
- Overview
- Installing
- Getting Started
- Advanced Usage
- File Logic
- Version Differences
- Contributing
- Projects Using SUCC