mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Update Optional.cs
- use more efficient empty assignments - use string interpolation - adjust method access to minimal needed
This commit is contained in:
@@ -19,7 +19,7 @@ namespace mRemoteNG.Tools
|
||||
/// </summary>
|
||||
public Optional()
|
||||
{
|
||||
_optional = new T[0];
|
||||
_optional = Array.Empty<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -30,7 +30,7 @@ namespace mRemoteNG.Tools
|
||||
{
|
||||
_optional = value != null
|
||||
? new[] {value}
|
||||
: new T[0];
|
||||
: Array.Empty<T>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -97,9 +97,7 @@ namespace mRemoteNG.Tools
|
||||
if (_optional[0] is IComparable<T>)
|
||||
return ((IComparable<T>)_optional[0]).CompareTo(other.First());
|
||||
|
||||
throw new ArgumentException(string.Format(
|
||||
"Cannot compare objects. Optional type {0} is not comparable to itself",
|
||||
typeof(T).FullName));
|
||||
throw new ArgumentException($"Cannot compare objects. Optional type {typeof(T).FullName} is not comparable to itself");
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -121,7 +119,7 @@ namespace mRemoteNG.Tools
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Equals(Optional<T> other)
|
||||
private bool Equals(Optional<T> other)
|
||||
{
|
||||
var otherObj = other.FirstOrDefault();
|
||||
var thisObj = _optional.FirstOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user