System.Data.ExprException.UnsupportedOperator C# (CSharp) Метод

UnsupportedOperator() публичный статический Метод

public static UnsupportedOperator ( int op ) : Exception
op int
Результат Exception
        public static Exception UnsupportedOperator(int op)
        {
            return _Eval(SR.Format(SR.Expr_UnsupportedOperator, Operators.ToString(op)));
        }

Usage Example

Пример #1
0
        private object EvalUnaryOp(int op, object vl)
        {
            object value = DBNull.Value;

            if (DataExpression.IsUnknown(vl))
            {
                return(DBNull.Value);
            }

            StorageType storageType;

            switch (op)
            {
            case Operators.Noop:
                return(vl);

            case Operators.UnaryPlus:
                storageType = DataStorage.GetStorageType(vl.GetType());
                if (ExpressionNode.IsNumericSql(storageType))
                {
                    return(vl);
                }
                throw ExprException.TypeMismatch(ToString());

            case Operators.Negative:
                // the have to be better way for doing this..
                storageType = DataStorage.GetStorageType(vl.GetType());
                if (ExpressionNode.IsNumericSql(storageType))
                {
                    switch (storageType)
                    {
                    case StorageType.Byte:
                        value = -(byte)vl;
                        break;

                    case StorageType.Int16:
                        value = -(short)vl;
                        break;

                    case StorageType.Int32:
                        value = -(int)vl;
                        break;

                    case StorageType.Int64:
                        value = -(long)vl;
                        break;

                    case StorageType.Single:
                        value = -(float)vl;
                        break;

                    case StorageType.Double:
                        value = -(double)vl;
                        break;

                    case StorageType.Decimal:
                        value = -(decimal)vl;
                        break;

                    case StorageType.SqlDecimal:
                        value = -(SqlDecimal)vl;
                        break;

                    case StorageType.SqlDouble:
                        value = -(SqlDouble)vl;
                        break;

                    case StorageType.SqlSingle:
                        value = -(SqlSingle)vl;
                        break;

                    case StorageType.SqlMoney:
                        value = -(SqlMoney)vl;
                        break;

                    case StorageType.SqlInt64:
                        value = -(SqlInt64)vl;
                        break;

                    case StorageType.SqlInt32:
                        value = -(SqlInt32)vl;
                        break;

                    case StorageType.SqlInt16:
                        value = -(SqlInt16)vl;
                        break;

                    default:
                        Debug.Fail("Missing a type conversion");
                        value = DBNull.Value;
                        break;
                    }
                    return(value);
                }

                throw ExprException.TypeMismatch(ToString());

            case Operators.Not:
                if (vl is SqlBoolean)
                {
                    if (((SqlBoolean)vl).IsFalse)
                    {
                        return(SqlBoolean.True);
                    }
                    else if (((SqlBoolean)vl).IsTrue)
                    {
                        return(SqlBoolean.False);
                    }
                    throw ExprException.UnsupportedOperator(op);      // or should the result of not SQLNull  be SqlNull ?
                }
                else
                {
                    if (DataExpression.ToBoolean(vl) != false)
                    {
                        return(false);
                    }
                    return(true);
                }

            default:
                throw ExprException.UnsupportedOperator(op);
            }
        }
All Usage Examples Of System.Data.ExprException::UnsupportedOperator