Struct NamedObject<T>
Structure that allows labeling any object.
Implements
Inherited Members
Namespace: TheXDS.MCART.Types
Assembly: MCART.dll
Syntax
public readonly struct NamedObject<T> : INameable
Type Parameters
Name | Description |
---|---|
T | Object type. |
Constructors
| Edit this page View SourceNamedObject(string, T)
Structure that allows labeling any object.
Declaration
public NamedObject(string name, T value)
Parameters
Type | Name | Description |
---|---|---|
string | name | Object's label. |
T | value | Object to label. |
NamedObject(T)
Initializes a new instance of the structure NamedObject<T> by setting a value along with an auto-generated label based on ToString().
Declaration
public NamedObject(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Object to label. |
NamedObject(T, string)
Initialies a new instance of the structure NamedObject<T>
Declaration
[Obsolete("The recommended signature for this constructor has changed. Please use NamedObject<T>(string, T) instead.")]
public NamedObject(T value, string name)
Parameters
Type | Name | Description |
---|---|---|
T | value | Object to label. |
string | name | Object's label. |
Properties
| Edit this page View SourceName
Object's label.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Value
Object's value.
Declaration
public T Value { get; }
Property Value
Type | Description |
---|---|
T |
Methods
| Edit this page View SourceEquals(object?)
Compares equality between this NamedObject<T> and another object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | Object to compare against this instance. |
Returns
Type | Description |
---|---|
bool | true if both instances are considered equal, false otherwise. |
Overrides
| Edit this page View SourceGetHashCode()
Gets the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code for this instance. |
Overrides
| Edit this page View SourceInfer(T)
Infers the label for an object.
Declaration
public static string Infer(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj | Object to infer a label for. |
Returns
Type | Description |
---|---|
string | The inferred name of the object or ToString() if no appropriate label can be inferred. |
Operators
| Edit this page View Sourceoperator ==(NamedObject<T>, NamedObject<T>)
Compares equality between two instances of NamedObject<T>.
Declaration
public static bool operator ==(NamedObject<T> left, NamedObject<T> right)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | left | Object to compare. |
NamedObject<T> | right | Object to compare against. |
Returns
Type | Description |
---|---|
bool | true if both instances are considered equal, false otherwise. |
implicit operator NamedObject<T>(KeyValuePair<string, T>)
Implicitly converts a KeyValuePair<TKey, TValue> into a NamedObject<T>.
Declaration
public static implicit operator NamedObject<T>(KeyValuePair<string, T> keyValuePair)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<string, T> | keyValuePair | Object to convert. |
Returns
Type | Description |
---|---|
NamedObject<T> |
implicit operator NamedObject<T>((string, T))
Implicitly converts a (T1, T2) into a NamedObject<T>.
Declaration
public static implicit operator NamedObject<T>((string, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
(string, T) | tuple | Object to convert. |
Returns
Type | Description |
---|---|
NamedObject<T> |
implicit operator NamedObject<T>((T, string))
Implicitly converts a (T1, T2) into a NamedObject<T>.
Declaration
public static implicit operator NamedObject<T>((T, string) tuple)
Parameters
Type | Name | Description |
---|---|---|
(T, string) | tuple | Object to convert. |
Returns
Type | Description |
---|---|
NamedObject<T> |
implicit operator KeyValuePair<string, T>(NamedObject<T>)
Implicitly converts a NamedObject<T> into a KeyValuePair<TKey, TValue>.
Declaration
public static implicit operator KeyValuePair<string, T>(NamedObject<T> namedObj)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | namedObj | Object to convert. |
Returns
Type | Description |
---|---|
KeyValuePair<string, T> |
implicit operator string(NamedObject<T>)
Implicitly converts a NamedObject<T> into a string.
Declaration
public static implicit operator string(NamedObject<T> namedObj)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | namedObj | Object to convert. |
Returns
Type | Description |
---|---|
string |
implicit operator (string, T)(NamedObject<T>)
Implicitly converts a (T1, T2) into a NamedObject<T>.
Declaration
public static implicit operator (string, T)(NamedObject<T> value)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | value | Object to convert. |
Returns
Type | Description |
---|---|
(string, T) |
implicit operator (T, string)(NamedObject<T>)
Implicitly converts a (T1, T2) into a NamedObject<T>.
Declaration
public static implicit operator (T, string)(NamedObject<T> value)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | value | Object to convert. |
Returns
Type | Description |
---|---|
(T, string) |
implicit operator T(NamedObject<T>)
Implicitly converts a NamedObject<T> into a T
.
Declaration
public static implicit operator T(NamedObject<T> namedObj)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | namedObj | Object to convert. |
Returns
Type | Description |
---|---|
T |
implicit operator NamedObject<T>(T)
Implicitly converts a T
into a NamedObject<T>.
Declaration
public static implicit operator NamedObject<T>(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj | Object to convert. |
Returns
Type | Description |
---|---|
NamedObject<T> |
operator !=(NamedObject<T>, NamedObject<T>)
Checks if two instances of NamedObject<T> are considered different.
Declaration
public static bool operator !=(NamedObject<T> left, NamedObject<T> right)
Parameters
Type | Name | Description |
---|---|---|
NamedObject<T> | left | Object to compare. |
NamedObject<T> | right | Object to compare against. |
Returns
Type | Description |
---|---|
bool | true if both instances are considered different, false otherwise. |