Friday, June 30, 2017

Abiathar API - Configuration

Last time, we looked at the "lifecycle" events that come through the event bus. Some of those have to do with configuration storage in the project file.

All configuration objects need to inherit from FleexConfig. That class provides serialization and deserialization of the public fields. If the class has FleexConfHostAttribute, all public fields will be marked serializable, unless they have FleexConfExemptAttribute. Otherwise, all serializable fields must be marked with FleexConfEntryAttribute. If a field has FleexConfLoadOnlyAttribute, it will be loaded but not saved; this allows for smooth deprecation of old entries. If an entry has FleexConfSaveIfNonNullAttribute, it will only be written if it's not null; this saves space. If it has FleexConfSaveIfNotEqAttribute (which takes a parameter), it will only be written if it doesn't have that value; this also saves space. To have a comment placed before an entry, give it FleexConfCommentAttribute; this is how the guidance in editor.aconf is generated.

Supported types include strings, every value type with a Parse method, lists, and subclasses of FleexConfig.

If your config object should do some special logic after being loaded, override the OnLoad method.

No comments:

Post a Comment