Struct UserDataStorage
Provides access to user data associated with the object.
Inherited Members
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 SourceCopyTo(Object)
Replaces user data of the object with the copy of the current one.
Declaration
public void CopyTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object which user data has to be replaced with the copy of the current one. |
Equals(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 |
Overrides
| Improve this Doc View SourceGet<TValue>(UserDataSlot<TValue>)
Gets user data.
Declaration
public TValue Get<TValue>(UserDataSlot<TValue> slot)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
TValue | User data; or |
Type Parameters
Name | Description |
---|---|
TValue | Type of data. |
Get<TValue>(UserDataSlot<TValue>, TValue)
Gets user data.
Declaration
public TValue Get<TValue>(UserDataSlot<TValue> slot, TValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
TValue | defaultValue | Default value to be returned if no user data contained in this collection. |
Returns
Type | Description |
---|---|
TValue | User data. |
Type Parameters
Name | Description |
---|---|
TValue | 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. |
Overrides
| Improve this Doc View SourceGetOrSet<TValue>(UserDataSlot<TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<TValue>(UserDataSlot<TValue> slot)
where TValue : new()
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
TValue | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
TValue | The type of user data associated with arbitrary object. |
GetOrSet<TValue>(UserDataSlot<TValue>, ValueFunc<TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<TValue>(UserDataSlot<TValue> slot, in ValueFunc<TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
ValueFunc<TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
TValue | The type of user data associated with arbitrary object. |
GetOrSet<TValue>(UserDataSlot<TValue>, Func<TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<TValue>(UserDataSlot<TValue> slot, Func<TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
Func<TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
TValue | The type of user data associated with arbitrary object. |
GetOrSet<TBase, T>(UserDataSlot<TBase>)
Gets existing user data or creates a new data and return it.
Declaration
public TBase GetOrSet<TBase, T>(UserDataSlot<TBase> slot)
where T : class, TBase, new()
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TBase> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
TBase | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
TBase | The type of user data associated with arbitrary object. |
T | The derived type with public parameterless constructor. |
GetOrSet<T, TValue>(UserDataSlot<TValue>, T, ValueFunc<T, TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<T, TValue>(UserDataSlot<TValue> slot, T arg, in ValueFunc<T, TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
T | arg | The argument to be passed into factory. |
ValueFunc<T, TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T | The type of the argument to be passed into factory. |
TValue | The type of user data associated with arbitrary object. |
GetOrSet<T, TValue>(UserDataSlot<TValue>, T, Func<T, TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<T, TValue>(UserDataSlot<TValue> slot, T arg, Func<T, TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
T | arg | The argument to be passed into factory. |
Func<T, TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | The data associated with the slot. |
Type Parameters
Name | Description |
---|---|
T | The type of the argument to be passed into factory. |
TValue | The type of user data associated with arbitrary object. |
GetOrSet<T1, T2, TValue>(UserDataSlot<TValue>, T1, T2, ValueFunc<T1, T2, TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<T1, T2, TValue>(UserDataSlot<TValue> slot, T1 arg1, T2 arg2, in ValueFunc<T1, T2, TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | 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, TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | 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 second argument to be passed into factory. |
TValue | The type of user data associated with arbitrary object. |
GetOrSet<T1, T2, TValue>(UserDataSlot<TValue>, T1, T2, Func<T1, T2, TValue>)
Gets existing user data or creates a new data and return it.
Declaration
public TValue GetOrSet<T1, T2, TValue>(UserDataSlot<TValue> slot, T1 arg1, T2 arg2, Func<T1, T2, TValue> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | 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. |
Func<T1, T2, TValue> | valueFactory | The value supplier which is called when no user data exists. |
Returns
Type | Description |
---|---|
TValue | 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 second argument to be passed into factory. |
TValue | The type of user data associated with arbitrary object. |
Remove<TValue>(UserDataSlot<TValue>)
Removes user data slot.
Declaration
public bool Remove<TValue>(UserDataSlot<TValue> slot)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
Returns
Type | Description |
---|---|
Boolean | true, if data is removed from this collection. |
Type Parameters
Name | Description |
---|---|
TValue | The type of user data. |
Remove<TValue>(UserDataSlot<TValue>, out TValue)
Removes user data slot.
Declaration
public bool Remove<TValue>(UserDataSlot<TValue> slot, out TValue userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
TValue | userData | Remove user data. |
Returns
Type | Description |
---|---|
Boolean | true, if data is removed from this collection. |
Type Parameters
Name | Description |
---|---|
TValue | The type of user data. |
Set<TValue>(UserDataSlot<TValue>, TValue)
Sets user data.
Declaration
public void Set<TValue>(UserDataSlot<TValue> slot, TValue userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
TValue | userData | User data to be saved in this collection. |
Type Parameters
Name | Description |
---|---|
TValue | 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. |
Overrides
| Improve this Doc View SourceTryGet<TValue>(UserDataSlot<TValue>, out TValue)
Tries to get user data.
Declaration
public bool TryGet<TValue>(UserDataSlot<TValue> slot, out TValue userData)
Parameters
Type | Name | Description |
---|---|---|
UserDataSlot<TValue> | slot | The slot identifying user data. |
TValue | userData | User data. |
Returns
Type | Description |
---|---|
Boolean | true, if user data slot exists in this collection. |
Type Parameters
Name | Description |
---|---|
TValue | 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. |