Class ValueStore
Unity compatible store of nested string key/value pairs.
Inheritance
Implements
Namespace: sttz.Trimmer
Assembly: Trimmer.dll
Syntax
[Serializable]
public class ValueStore : ISerializationCallbackReceiver
Remarks
The ValueStore is used to serialize the nested Option values in
Unity using its ISerializationCallbackReceiver callbacks.
Properties
| Improve this Doc View SourceRootCount
Number of root nodes in this store.
Declaration
public int RootCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Roots
Enumerate the root nodes in this store.
Declaration
public IEnumerable<ValueStore.RootNode> Roots { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<ValueStore.RootNode> |
Methods
| Improve this Doc View SourceAddRoot(String, String)
Add a new root node.
Declaration
public ValueStore.RootNode AddRoot(string name, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.String | value |
Returns
| Type | Description |
|---|---|
| ValueStore.RootNode |
Clear()
Removes all content form the store.
Declaration
public void Clear()
Clone()
Create a clone of the current store.
Declaration
public ValueStore Clone()
Returns
| Type | Description |
|---|---|
| ValueStore |
GetOrCreateRoot(String)
Get a root node by name, create it if it doesn't exist.
Declaration
public ValueStore.RootNode GetOrCreateRoot(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Returns
| Type | Description |
|---|---|
| ValueStore.RootNode |
GetRoot(String)
Get a root node by name.
Declaration
public ValueStore.RootNode GetRoot(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Returns
| Type | Description |
|---|---|
| ValueStore.RootNode |
IsDirty(Boolean)
Check if the store has been modified and optionally reset the modification state.
Declaration
public bool IsDirty(bool clear = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | clear |
Returns
| Type | Description |
|---|---|
| System.Boolean |
RemoveRoot(String)
Remove a root node.
Declaration
public void RemoveRoot(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Explicit Interface Implementations
| Improve this Doc View SourceISerializationCallbackReceiver.OnAfterDeserialize()
Declaration
void ISerializationCallbackReceiver.OnAfterDeserialize()
ISerializationCallbackReceiver.OnBeforeSerialize()
Unity doesn't support serialization of types that contain themselves,
like in this case Node that contains lists of Node.
To enable this we don't serialize the nested lists but instead just
the size of the lists (i.e. Node.numVariants and Node.numChildren)
and then use ISerializationCallbackReceiver to flatten and
unpack the tree before and after Unity serializes it.
We process the nodes in the same order flattening and unpacking them and that allows us to get away with just serializing the list lengths.
Declaration
void ISerializationCallbackReceiver.OnBeforeSerialize()