Fixed a couple Optional errors
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Discord.API
|
|||||||
{
|
{
|
||||||
private readonly T _value;
|
private readonly T _value;
|
||||||
|
|
||||||
/// <summary> Gets the value for this paramter, or default(T) if unspecified. </summary>
|
/// <summary> Gets the value for this paramter. </summary>
|
||||||
public T Value
|
public T Value
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -22,8 +22,6 @@ namespace Discord.API
|
|||||||
/// <summary> Returns true if this value has been specified. </summary>
|
/// <summary> Returns true if this value has been specified. </summary>
|
||||||
public bool IsSpecified { get; }
|
public bool IsSpecified { get; }
|
||||||
|
|
||||||
object IOptional.Value => _value;
|
|
||||||
|
|
||||||
/// <summary> Creates a new Parameter with the provided value. </summary>
|
/// <summary> Creates a new Parameter with the provided value. </summary>
|
||||||
public Optional(T value)
|
public Optional(T value)
|
||||||
{
|
{
|
||||||
@@ -40,12 +38,14 @@ namespace Discord.API
|
|||||||
if (other == null) return false;
|
if (other == null) return false;
|
||||||
return _value.Equals(other);
|
return _value.Equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0;
|
public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0;
|
||||||
|
|
||||||
public override string ToString() => IsSpecified ? _value?.ToString() : null;
|
public override string ToString() => IsSpecified ? _value?.ToString() : null;
|
||||||
private string DebuggerDisplay => IsSpecified ? _value.ToString() : "<unspecified>";
|
private string DebuggerDisplay => IsSpecified ? _value.ToString() : "<unspecified>";
|
||||||
|
|
||||||
public static implicit operator Optional<T>(T value) => new Optional<T>(value);
|
public static implicit operator Optional<T>(T value) => new Optional<T>(value);
|
||||||
public static explicit operator T(Optional<T> value) => value.Value;
|
public static explicit operator T(Optional<T> value) => value.Value;
|
||||||
|
|
||||||
|
object IOptional.Value => Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user