Пример #1
0
        private static bool TryCoerceBoth(object mine, object other, out object mineCoerced, out object otherCoerced)
        {
            //this will not be called with null in either value
            Type common;

            if (GetCommonType(mine, other, out common) ||
                !Coercer.TryCoerce(mine, common, out mineCoerced) ||
                !Coercer.TryCoerce(other, common, out otherCoerced))
            {
                mineCoerced  = null;
                otherCoerced = null;
                return(false);
            }

            return(true);
        }
Пример #2
0
        private static bool TryCoerceLeftIntoRight(object mine, object other, out object mineCoerced, out object otherCoerced)
        {
            if (mine == null ||
                other == null ||
                !Coercions.TryGetValue(mine.GetType(), out var validList) ||
                !validList.Contains(other.GetType()) ||
                !Coercer.TryCoerce(mine, other.GetType(), out var coercedValue))
            {
                mineCoerced  = null;
                otherCoerced = null;
                return(false);
            }

            mineCoerced  = coercedValue;
            otherCoerced = other;
            return(true);
        }