Beispiel #1
0
        private static bool CompareGuard(ObjectEnum <TEnum> left, ObjectEnum <TEnum> right)
        {
            var rightType = right.GetType();

            if (!left.IsTypeEquivalent(rightType))
            {
                throw new InvalidOperationException($"Cannot compare an object of Type {left.GetType()} to an object of Type {rightType}");
            }

            return(true);
        }
Beispiel #2
0
 public bool Equals(ObjectEnum <TEnum> other)
 => Equals(other as object);
Beispiel #3
0
 public int CompareTo(ObjectEnum <TEnum> other)
 // ReSharper disable once PossibleNullReferenceException; checked in static ctor
 => other == null ? 1 : (_value as Enum).CompareTo(other._value);
Beispiel #4
0
 /// <summary>
 /// Indicates whether a specified value exists for this <see cref="ObjectEnum{TEnum}"/>.
 /// </summary>
 /// <param name="value">The value to check.</param>
 /// <returns><see langword="true" /> if <paramref name="value" />is defined and the <c>Type</c> of <paramref name="value"/>is equivalent; otherwise, <see langword="false" />.</returns>
 public bool IsDefined(ObjectEnum <TEnum> value)
 => value != null &&
 IsTypeEquivalent(value.GetType()) &&
 IsDefined((TEnum)value);