Exemple #1
0
        /// <summary>
        /// Indicates whether the current <see cref="Exceptional{T}"/> is equal to another <see cref="Exceptional{T}"/>
        /// </summary>
        /// <param name="other">An <see cref="Exceptional{T}"/> to compare with this <see cref="Exceptional{T}"/>.</param>
        /// <returns>true if the current <see cref="Exceptional{T}"/> object is equal to the other parameter; otherwise, false.</returns>
        public bool Equals(Exceptional <T> other)
        {
            bool result;

            if (object.Equals(Exception, null) && object.Equals(other.Exception, null))
            {
                result = true;
            }
            else if (object.Equals(Exception, null) || object.Equals(other.Exception, null))
            {
                result = false;
            }
            else
            {
                var typeBased = Exception.GetType() == other.Exception.GetType();
                result = typeBased && object.Equals(Value, other.Value);
            }

            return(result);
        }
Exemple #2
0
 /// <summary>
 /// Binds <see cref="Exceptional{T}"/> into <see cref="Exceptional{Res}"/>
 /// </summary>
 public static Exceptional <Res> Bind <R, Res>(this Exceptional <R> exceptional, Func <R, Exceptional <Res> > func)
 => exceptional.Exception == null?func(exceptional.Value) : new Exceptional <Res>(exceptional.Exception);