Microsoft.Cci.ExpressionHelper.IsIntegralMinusOne C# (CSharp) Метод

IsIntegralMinusOne() приватный Метод

private IsIntegralMinusOne ( ICompileTimeConstant constExpression ) : bool
constExpression ICompileTimeConstant
Результат bool
    public static bool IsIntegralMinusOne(ICompileTimeConstant constExpression) {
      IConvertible/*?*/ ic = constExpression.Value as IConvertible;
      if (ic == null) return false;
      switch (ic.GetTypeCode()) {
        case System.TypeCode.SByte: return ic.ToSByte(null) == -1;
        case System.TypeCode.Int16: return ic.ToInt16(null) == -1;
        case System.TypeCode.Int32: return ic.ToInt32(null) == -1;
        case System.TypeCode.Int64: return ic.ToInt64(null) == -1;
        case System.TypeCode.Byte: return ic.ToByte(null) == byte.MaxValue;
        case System.TypeCode.UInt16: return ic.ToUInt16(null) == ushort.MaxValue;
        case System.TypeCode.UInt32: return ic.ToUInt32(null) == uint.MaxValue;
        case System.TypeCode.UInt64: return ic.ToUInt64(null) == ulong.MaxValue;
      }
      return false;
    }

Same methods

ExpressionHelper::IsIntegralMinusOne ( IExpression expression ) : bool

Usage Example

Пример #1
0
        public static bool IsIntegralMinusOne(IExpression expression)
        {
            ICompileTimeConstant /*?*/ constExpression = expression as ICompileTimeConstant;

            if (constExpression == null)
            {
                return(false);
            }
            return(ExpressionHelper.IsIntegralMinusOne(constExpression));
        }