public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            switch (GetTypeCode(type))
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new ExclusiveOrSByte()));

            case TypeCode.Byte: return(s_byte ?? (s_byte = new ExclusiveOrByte()));

            case TypeCode.Int16: return(s_int16 ?? (s_int16 = new ExclusiveOrInt16()));

            case TypeCode.Int32: return(s_int32 ?? (s_int32 = new ExclusiveOrInt32()));

            case TypeCode.Int64: return(s_int64 ?? (s_int64 = new ExclusiveOrInt64()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64()));

            case TypeCode.Boolean: return(s_bool ?? (s_bool = new ExclusiveOrBool()));

            default:
                throw Error.ExpressionNotSupportedForType("ExclusiveOr", type);
            }
        }
Beispiel #2
0
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new ExclusiveOrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new ExclusiveOrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new ExclusiveOrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new ExclusiveOrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new ExclusiveOrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new ExclusiveOrBoolean()));

            default:
                throw ContractUtils.Unreachable;
            }
        }
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new ExclusiveOrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new ExclusiveOrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new ExclusiveOrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new ExclusiveOrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new ExclusiveOrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new ExclusiveOrBoolean()));

            default:
                throw Error.ExpressionNotSupportedForType("ExclusiveOr", type);
            }
        }
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            Type underlyingType = type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : type.GetNonNullableType();

            switch (underlyingType.GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new ExclusiveOrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new ExclusiveOrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new ExclusiveOrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new ExclusiveOrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new ExclusiveOrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new ExclusiveOrBoolean()));

            default:
                throw Error.ExpressionNotSupportedForType("ExclusiveOr", type);
            }
        }
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            switch (GetTypeCode(type))
            {
                case TypeCode.SByte: return s_SByte ?? (s_SByte = new ExclusiveOrSByte());
                case TypeCode.Byte: return s_byte ?? (s_byte = new ExclusiveOrByte());
                case TypeCode.Int16: return s_int16 ?? (s_int16 = new ExclusiveOrInt16());
                case TypeCode.Int32: return s_int32 ?? (s_int32 = new ExclusiveOrInt32());
                case TypeCode.Int64: return s_int64 ?? (s_int64 = new ExclusiveOrInt64());

                case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16());
                case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32());
                case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64());
                case TypeCode.Boolean: return s_bool ?? (s_bool = new ExclusiveOrBool());

                default:
                    throw Error.ExpressionNotSupportedForType("ExclusiveOr", type);
            }
        }
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            Type underlyingType = type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : type.GetNonNullableType();

            switch (underlyingType.GetTypeCode())
            {
                case TypeCode.SByte: return s_SByte ?? (s_SByte = new ExclusiveOrSByte());
                case TypeCode.Int16: return s_Int16 ?? (s_Int16 = new ExclusiveOrInt16());
                case TypeCode.Int32: return s_Int32 ?? (s_Int32 = new ExclusiveOrInt32());
                case TypeCode.Int64: return s_Int64 ?? (s_Int64 = new ExclusiveOrInt64());
                case TypeCode.Byte: return s_Byte ?? (s_Byte = new ExclusiveOrByte());
                case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new ExclusiveOrUInt16());
                case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new ExclusiveOrUInt32());
                case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new ExclusiveOrUInt64());
                case TypeCode.Boolean: return s_Boolean ?? (s_Boolean = new ExclusiveOrBoolean());
                default:
                    throw Error.ExpressionNotSupportedForType("ExclusiveOr", type);
            }
        }