[DebuggerStepThrough, DebuggerHidden, MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ValidateBinaryOperatorAllowed(this IFlexpressionConstraint source, OverloadableCodeBinarySymmetricOperator binaryOperator, int argsCount)
        {
            var res = source.IsBinaryOperatorAllowed(binaryOperator, argsCount);

            switch (res)
            {
            case FXConstraintResult.Allowed:
                return;

            case FXConstraintResult.OperationNotAllowed:
                throw new DomainConstraintBrokenException($"Binary operator '{binaryOperator.GetSymbol()}' ({binaryOperator}) is not allowed  by domain constraint ({source.GetType().Name}).");

            default:
                throw new DomainConstraintBrokenException($"Binary operator '{binaryOperator.GetSymbol()}' ({binaryOperator}) is not allowed for the number of args={argsCount} by domain constraint ({source.GetType().Name}).");
            }
        }
示例#2
0
        public static DefinableFxBinaryOperator ToDefinableFxOperator(this OverloadableCodeBinarySymmetricOperator source)
        {
            if (source == OverloadableCodeBinarySymmetricOperator.And ||
                source == OverloadableCodeBinarySymmetricOperator.Or)
            {
                throw new ArgumentOutOfRangeException(nameof(source),
                                                      $"Binary operator '{source.GetSymbol()}' ({source}) is not definable flexpression operator.");
            }

            var res = (DefinableFxBinaryOperator)source;

            return(res);
        }