AbstractCollectionTypeProto Class |
Namespace: KSPDev.ConfigUtils
The AbstractCollectionTypeProto type exposes the following members.
| Name | Description | |
|---|---|---|
| AbstractCollectionTypeProto | Initializes a new instance of the AbstractCollectionTypeProto class |
| Name | Description | |
|---|---|---|
| AddItem | Adds an item into the collection. | |
| ClearItems | Removes all items from the collection. | |
| GetEnumerator | Returns enumerable object for the collection. | |
| GetItemType | Returns type of items in the collection. |
All descendants of this class must implement a constructor which accepts a single argument: the type of the collection. Constructor can throw ArgumentException if passed type is unacceptable.
class MyBooleanCollection { public void AddItem(bool itemValue) { // ...some custom code... } public IEnumerable GetMyVeryCustomIterator() { // ...some custom code... return res; } } class MyBooleanCollectionProto : AbstractCollectionTypeProto { public MyBooleanCollectionProto() : base(typeof(bool)) {} public override Type GetItemType() { return typeof(bool); } public override IEnumerable GetEnumerator(object instance) { return (instance as MyBooleanCollection).GetMyVeryCustomIterator(); } public override void AddItem(object instance, object item) { (instance as MyBooleanCollection).AddItem((bool) item); } }