Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public bool Equals(ObjectEnum <TEnum> other)
 => Equals(other as object);
Ejemplo n.º 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);
Ejemplo n.º 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);