Struct UserDataStorage
Provides access to user data associated with the object.
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public struct UserDataStorage
Remarks
This is by-ref struct because user data should have the same lifetime as its owner.
Methods
| Improve this Doc View SourceEquals(Object)
Determines whether this storage is attached to the given object.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | Other object to check. |
Returns
Type | Description |
---|---|
Boolean | true, if this storage is attached to |
Get<V>(UserDataSlot<V>, V)
Gets user data.
Declaration
public V Get<V>(UserDataSlot<V> slot, V defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
V | defaultValue | Default value to be returned if no user data contained in this collection. |
Returns
Type | Description |
---|---|
V | User data. |
Type Parameters
Name | Description |
---|---|
V | Type of data. |
GetHashCode()
Computes identity hash code for this storage.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The identity hash code for this storage. |
GetOrSet<V>(UserDataSlot<V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<V>(UserDataSlot<V> slot)
where V : new()
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
V | The type of user data associated with arbitrary object. |
GetOrSet<V>(UserDataSlot<V>, Func<V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<V>(UserDataSlot<V> slot, Func<V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
DotNext.Func<V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
V | The type of user data associated with arbitrary object. |
GetOrSet<V>(UserDataSlot<V>, ValueFunc<V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<V>(UserDataSlot<V> slot, in ValueFunc<V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
ValueFunc<V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
V | The type of user data associated with arbitrary object. |
GetOrSet<B, D>(UserDataSlot<B>)
Gets existing user data or creates a new data and return it.
Declaration
public B GetOrSet<B, D>(UserDataSlot<B> slot)
where D : class, B, new()
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<B> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
B | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
B | The type of user data associated with arbitrary object. |
D | The derived type with public parameterless constructor. |
GetOrSet<T, V>(UserDataSlot<V>, T, Func<T, V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<T, V>(UserDataSlot<V> slot, T arg, Func<T, V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
T | arg | The argument to be passed into factory. |
DotNext.Func<T, V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T | The type of the argument to be passed into factory. |
V | The type of user data associated with arbitrary object. |
GetOrSet<T, V>(UserDataSlot<V>, T, ValueFunc<T, V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<T, V>(UserDataSlot<V> slot, T arg, in ValueFunc<T, V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
T | arg | The argument to be passed into factory. |
ValueFunc<T, V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T | The type of the argument to be passed into factory. |
V | The type of user data associated with arbitrary object. |
GetOrSet<T1, T2, V>(UserDataSlot<V>, T1, T2, Func<T1, T2, V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<T1, T2, V>(UserDataSlot<V> slot, T1 arg1, T2 arg2, Func<T1, T2, V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
T1 | arg1 | The first argument to be passed into factory. |
T2 | arg2 | The second argument to be passed into factory. |
DotNext.Func<T1, T2, V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first argument to be passed into factory. |
T2 | The type of the first argument to be passed into factory. |
V | The type of user data associated with arbitrary object. |
GetOrSet<T1, T2, V>(UserDataSlot<V>, T1, T2, ValueFunc<T1, T2, V>)
Gets existing user data or creates a new data and return it.
Declaration
public V GetOrSet<T1, T2, V>(UserDataSlot<V> slot, T1 arg1, T2 arg2, in ValueFunc<T1, T2, V> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
T1 | arg1 | The first argument to be passed into factory. |
T2 | arg2 | The second argument to be passed into factory. |
ValueFunc<T1, T2, V> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
V | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first argument to be passed into factory. |
T2 | The type of the first argument to be passed into factory. |
V | The type of user data associated with arbitrary object. |
Remove<V>(UserDataSlot<V>)
Removes user data slot.
Declaration
public bool Remove<V>(UserDataSlot<V> slot)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
Boolean | true, if data is removed from this collection. |
Type Parameters
Name | Description |
---|---|
V | The type of user data. |
Remove<V>(UserDataSlot<V>, out V)
Removes user data slot.
Declaration
public bool Remove<V>(UserDataSlot<V> slot, out V userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
V | userData | Remove user data. |
Returns
Type | Description |
---|---|
Boolean | true, if data is removed from this collection. |
Type Parameters
Name | Description |
---|---|
V | The type of user data. |
Set<V>(UserDataSlot<V>, V)
Sets user data.
Declaration
public void Set<V>(UserDataSlot<V> slot, V userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
V | userData | User data to be saved in this collection. |
Type Parameters
Name | Description |
---|---|
V | Type of data. |
ToString()
Returns textual representation of this storage.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of this storage. |
TryGet<V>(UserDataSlot<V>, out V)
Tries to get user data.
Declaration
public bool TryGet<V>(UserDataSlot<V> slot, out V userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<V> | slot | The slot identifying user data. |
V | userData | User data. |
Returns
Type | Description |
---|---|
Boolean | true, if user data slot exists in this collection. |
Type Parameters
Name | Description |
---|---|
V | Type of data. |
Operators
| Improve this Doc View SourceEquality(UserDataStorage, UserDataStorage)
Determines whether two stores are for the same object.
Declaration
public static bool operator ==(UserDataStorage first, UserDataStorage second)
Parameters
Type | Name | Description |
---|---|---|
UserDataStorage | first | The first storage to compare. |
UserDataStorage | second | The second storage to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if two stores are for the same object; otherwise, false. |
Inequality(UserDataStorage, UserDataStorage)
Determines whether two stores are not for the same object.
Declaration
public static bool operator !=(UserDataStorage first, UserDataStorage second)
Parameters
Type | Name | Description |
---|---|---|
UserDataStorage | first | The first storage to compare. |
UserDataStorage | second | The second storage to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if two stores are not for the same object; otherwise, false. |