Struct TypeNullability
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Represents detailed information about Type nullability.
public readonly struct TypeNullability : IEquatable<TypeNullability>
- Implements
- Inherited Members
- Extension Methods
Properties
ActualType
Specifies the actual Type.
public Type ActualType { get; }
Property Value
IsNullable
Specifies whether or not the ActualType is nullable.
public bool IsNullable { get; }
Property Value
UnderlyingType
Specifies the underlying Type. Will not be equal to ActualType only for nullable value types.
public Type UnderlyingType { get; }
Property Value
Methods
Create(Type, bool)
Creates a new TypeNullability instance.
[Pure]
public static TypeNullability Create(Type type, bool isNullable = false)
Parameters
typeTypeSource type.
isNullableboolSpecifies whether or not the result should be nullable. Equal to false by default. Will be ignored for nullable value types.
Returns
- TypeNullability
New TypeNullability instance.
Create<T>(bool)
Creates a new TypeNullability instance.
[Pure]
public static TypeNullability Create<T>(bool isNullable = false) where T : notnull
Parameters
isNullableboolSpecifies whether or not the result should be nullable. Equal to false by default.
Returns
- TypeNullability
New TypeNullability instance.
Type Parameters
TUnderlying type.
Equals(TypeNullability)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(TypeNullability other)
Parameters
otherTypeNullabilityAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetCommonType(TypeNullability?, TypeNullability?)
Returns a common TypeNullability instance for two instances.
[Pure]
public static TypeNullability? GetCommonType(TypeNullability? left, TypeNullability? right)
Parameters
leftTypeNullability?First type nullability.
rightTypeNullability?Second type nullability.
Returns
- TypeNullability?
null when
leftis null orrightis null or UnderlyingType properties are not equal, otherwiseleftwhen it is nullable, otherwiseright.
GetCommonTypeWith(TypeNullability?)
Returns a common TypeNullability instance for this instance and the provided other.
[Pure]
public TypeNullability? GetCommonTypeWith(TypeNullability? other)
Parameters
otherTypeNullability?Other type nullability.
Returns
- TypeNullability?
null when
otheris null or UnderlyingType properties are not equal, otherwise this when it is nullable, otherwiseother.
GetHashCode()
Returns the hash code for this instance.
[Pure]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
MakeNullable()
Creates a new TypeNullability instance from this instance with IsNullable set to true.
[Pure]
public TypeNullability MakeNullable()
Returns
- TypeNullability
New TypeNullability instance.
MakeRequired()
Creates a new TypeNullability instance from this instance with IsNullable set to false.
[Pure]
public TypeNullability MakeRequired()
Returns
- TypeNullability
New TypeNullability instance.
ToString()
Returns a string representation of this TypeNullability instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator ==(TypeNullability, TypeNullability)
Checks if a is equal to b.
[Pure]
public static bool operator ==(TypeNullability a, TypeNullability b)
Parameters
aTypeNullabilityFirst operand.
bTypeNullabilitySecond operand.
Returns
- bool
true when operands are equal, otherwise false.
operator !=(TypeNullability, TypeNullability)
Checks if a is not equal to b.
[Pure]
public static bool operator !=(TypeNullability a, TypeNullability b)
Parameters
aTypeNullabilityFirst operand.
bTypeNullabilitySecond operand.
Returns
- bool
true when operands are not equal, otherwise false.