Click or drag to resize

PersistentCustomFieldAttribute Class

Attribute for the persistent fields that can use custom type protos.
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#
[AttributeUsageAttribute(AttributeTargets.Field)]
public sealed class PersistentCustomFieldAttribute : BasePersistentFieldAttribute
Request Example View Source

The PersistentCustomFieldAttribute type exposes the following members.

Constructors
  NameDescription
Public methodPersistentCustomFieldAttribute
Creates attribute for persistent field with custom type protos.
Top
Examples

To provide own type proto for (de)serializing the field:

class CustomType {
  [PersistentCustomField("my/custom/type", typeProto: typeof(MyTypeProto))]
  public MyType field1;
}

If your custom type filed is a collection, you need to provide a collection proto handler. It can be one of the existing protos (e.g. GenericCollectionTypeProto or a custom one. Keep in mind that the collection fields must be initialized, or else they won't be handled.

class CustomTypes {
  [PersistentCustomField("my/custom/type", collectionProto: typeof(GenericCollectionTypeProto))]
  public List<string> field1 = new List<string>();
}
See Also