Click or drag to resize

BasePersistentFieldAttribute Class

A base for any persitent field annotation.
Inheritance Hierarchy

Namespace:  KSPDev.ConfigUtils
Assembly:  KSPDev_Utils.1.2 (in KSPDev_Utils.1.2.dll) Version: 1.2 for KSP v1.6+
Syntax
C#
public abstract class BasePersistentFieldAttribute : Attribute
Request Example View Source

The BasePersistentFieldAttribute type exposes the following members.

Constructors
  NameDescription
Protected methodBasePersistentFieldAttribute
Initializes a new instance of the BasePersistentFieldAttribute class
Top
Properties
  NameDescription
Public propertycollectionTypeProto
A proto that handles field's value as a collection of persistent values.
Public propertyordinaryTypeProto
A proto that (de)serializes field's value as a simple string.
Top
Fields
  NameDescription
Public fieldgroup
A tag for a group of fields.
Public fieldpath
Relative path to the value or node. Case-insensitive.
Top
Remarks
Descendands must initialize at least ordinaryTypeProto field. If collectionTypeProto is set then the field is considered a persistent collection of values.

See more examples in PersistentFieldsFileAttribute.

Examples
A "shortcut" attributes could be declared like this:
class MyTypeAttribute : AbstractPersistentFieldAttribute {
  public MyTypeAttribute(string cfgPath) : base(cfgPath) {
    ordinaryTypeProto = typeof(PrimitiveTypesProto);
  }
}

class MyTypesCollectionAttribute : AbstractPersistentFieldAttribute {
  public MyTypesCollectionAttribute(string cfgPath) : base(cfgPath) {
    ordinaryTypeProto = typeof(PrimitiveTypesProto);
    collectionTypeProto = typeof(GenericCollectionTypeProto);
  }
}
See Also