Show / Hide Table of Contents

Struct ReadOnlyValueReference<T>

Represents an immutable reference to the field.

Implements
IEquatable<ReadOnlyValueReference<T>>
IEqualityOperators<ReadOnlyValueReference<T>, ReadOnlyValueReference<T>, bool>
ISupplier<T>
IFunctional
ITypedReference<T>
Inherited Members
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public readonly struct ReadOnlyValueReference<T> : IEquatable<ReadOnlyValueReference<T>>, IEqualityOperators<ReadOnlyValueReference<T>, ReadOnlyValueReference<T>, bool>, ISupplier<T>, IFunctional, ITypedReference<T>
Type Parameters
Name Description
T

The type of the field.

Constructors

View Source

ReadOnlyValueReference(object, ref readonly T)

Represents an immutable reference to the field.

Declaration
public ReadOnlyValueReference(object owner, ref readonly T fieldRef)
Parameters
Type Name Description
object owner

An object that owns the field.

T fieldRef

The reference to the field.

View Source

ReadOnlyValueReference(ref readonly T)

Creates a reference to a static field.

Declaration
public ReadOnlyValueReference(ref readonly T staticFieldRef)
Parameters
Type Name Description
T staticFieldRef

A reference to the static field.

Remarks

If T is a value type then your static field MUST be marked with FixedAddressValueTypeAttribute. Otherwise, the behavior is unpredictable. Correctness of this constructor is based on the fact that static fields are stored as elements of object array allocated by the runtime in the Pinned Object Heap. It means that the address of the field cannot be changed by GC.

See Also
Internals of the POH
View Source

ReadOnlyValueReference(T[], int)

Creates a reference to an array element.

Declaration
public ReadOnlyValueReference(T[] array, int index)
Parameters
Type Name Description
T[] array

The array.

int index

The index of the array element.

Properties

View Source

IsEmpty

Gets a value indicating that is reference is empty.

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
View Source

Value

Gets a reference to the field.

Declaration
public ref readonly T Value { get; }
Property Value
Type Description
T

Methods

View Source

Equals(ReadOnlyValueReference<T>)

Declaration
public bool Equals(ReadOnlyValueReference<T> reference)
Parameters
Type Name Description
ReadOnlyValueReference<T> reference
Returns
Type Description
bool
View Source

Equals(object?)

Declaration
public override bool Equals(object? other)
Parameters
Type Name Description
object other
Returns
Type Description
bool
Overrides
ValueType.Equals(object)
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()
View Source

ToString()

Declaration
public override string? ToString()
Returns
Type Description
string
Overrides
ValueType.ToString()

Operators

View Source

explicit operator Func<T>(ReadOnlyValueReference<T>)

Returns a getter for the memory location.

Declaration
public static explicit operator Func<T>(ReadOnlyValueReference<T> reference)
Parameters
Type Name Description
ReadOnlyValueReference<T> reference

A reference to a value.

Returns
Type Description
Func<T>

A getter for the memory location.

View Source

implicit operator ReadOnlyLocalReference<T>(ReadOnlyValueReference<T>)

Converts the reference to the local reference.

Declaration
public static implicit operator ReadOnlyLocalReference<T>(ReadOnlyValueReference<T> reference)
Parameters
Type Name Description
ReadOnlyValueReference<T> reference

The reference to convert.

Returns
Type Description
ReadOnlyLocalReference<T>

The local reference the same value as reference.

View Source

implicit operator Variant(ReadOnlyValueReference<T>)

Converts the reference to variant value.

Declaration
public static implicit operator Variant(ReadOnlyValueReference<T> reference)
Parameters
Type Name Description
ReadOnlyValueReference<T> reference

The reference to convert.

Returns
Type Description
Variant

The variant value referencing the same value as reference.

View Source

implicit operator ReadOnlySpan<T>(ReadOnlyValueReference<T>)

Gets a span over the referenced value.

Declaration
public static implicit operator ReadOnlySpan<T>(ReadOnlyValueReference<T> reference)
Parameters
Type Name Description
ReadOnlyValueReference<T> reference

The value reference.

Returns
Type Description
ReadOnlySpan<T>

The span that contains Value; or empty span if reference is empty.

Explicit Interface Implementations

View Source

operator ==(ReadOnlyValueReference<T>, ReadOnlyValueReference<T>)

Determines whether the two references point to the same field.

Declaration
static bool operator ==(ReadOnlyValueReference<T> x, ReadOnlyValueReference<T> y)
Parameters
Type Name Description
ReadOnlyValueReference<T> x

The first reference to compare.

ReadOnlyValueReference<T> y

The second reference to compare.

Returns
Type Description
bool

true if both references are equal; otherwise, false.

View Source

operator !=(ReadOnlyValueReference<T>, ReadOnlyValueReference<T>)

Determines whether the two references point to the different fields.

Declaration
static bool operator !=(ReadOnlyValueReference<T> x, ReadOnlyValueReference<T> y)
Parameters
Type Name Description
ReadOnlyValueReference<T> x

The first reference to compare.

ReadOnlyValueReference<T> y

The second reference to compare.

Returns
Type Description
bool

true if both references are not equal; otherwise, false.

Implements

IEquatable<T>
IEqualityOperators<TSelf, TOther, TResult>
ISupplier<TResult>
IFunctional
ITypedReference<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾