API ReferenceSandbox
DataBagclass
A lightweight, lazily-allocated key/value store for stashing arbitrary typed data on an object. The backing dictionary isn't created until you store something, so empty bags are essentially free. Not thread-safe - use it from a single thread (usually the main thread).
object→DataBag
Constructors1
Showing 1 constructors
public DataBag()
No results match this filter.
Methods5
Showing 5 methods
public void Clear()
Remove everything from the bag.
Returns:
void—public T Get(string key, T fallback = null)
Get the value stored under `key`, or `fallback` if there's nothing there or it's a different type.
| Parameter | Type | Description |
|---|---|---|
| key | string | — |
| fallback = null | T | — |
Returns:
T—public bool Has(string key)
Whether anything is stored under `key`.
| Parameter | Type | Description |
|---|---|---|
| key | string | — |
Returns:
bool—public bool Remove(string key)
Remove the value stored under `key`. Returns true if something was removed.
| Parameter | Type | Description |
|---|---|---|
| key | string | — |
Returns:
bool—public void Set(string key, T value)
Store a value under `key`, replacing anything already there.
| Parameter | Type | Description |
|---|---|---|
| key | string | — |
| value | T | — |
Returns:
void—No results match this filter.