コード例 #1
0
ファイル: EqualInstruction.cs プロジェクト: zhufengGNSS/mono
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode())
            {
            case TypeCode.Boolean: return(_Boolean ?? (_Boolean = new EqualBoolean()));

            case TypeCode.SByte: return(_SByte ?? (_SByte = new EqualSByte()));

            case TypeCode.Byte: return(_Byte ?? (_Byte = new EqualByte()));

            case TypeCode.Char: return(_Char ?? (_Char = new EqualChar()));

            case TypeCode.String: return(_String ?? (_String = new EqualString()));

            case TypeCode.Int16: return(_Int16 ?? (_Int16 = new EqualInt16()));

            case TypeCode.Int32: return(_Int32 ?? (_Int32 = new EqualInt32()));

            case TypeCode.Int64: return(_Int64 ?? (_Int64 = new EqualInt64()));

            case TypeCode.UInt16: return(_UInt16 ?? (_UInt16 = new EqualInt16()));

            case TypeCode.UInt32: return(_UInt32 ?? (_UInt32 = new EqualInt32()));

            case TypeCode.UInt64: return(_UInt64 ?? (_UInt64 = new EqualInt64()));

            case TypeCode.Single: return(_Single ?? (_Single = new EqualSingle()));

            case TypeCode.Double: return(_Double ?? (_Double = new EqualDouble()));

            case TypeCode.Object:
                if (!type.IsValueType())
                {
                    return(_Reference ?? (_Reference = new EqualReference()));
                }
                // TODO: Nullable<T>
                throw new NotImplementedException();

            default:
                throw new NotImplementedException();
            }
        }
コード例 #2
0
ファイル: EqualInstruction.cs プロジェクト: Profit0004/mono
        public static Instruction Create(Type type) {
            // Boxed enums can be unboxed as their underlying types:
            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode()) {
                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new EqualBoolean());
                case TypeCode.SByte: return _SByte ?? (_SByte = new EqualSByte());
                case TypeCode.Byte: return _Byte ?? (_Byte = new EqualByte());
                case TypeCode.Char: return _Char ?? (_Char = new EqualChar());
                case TypeCode.String: return _String ?? (_String = new EqualString());
                case TypeCode.Int16: return _Int16 ?? (_Int16 = new EqualInt16());
                case TypeCode.Int32: return _Int32 ?? (_Int32 = new EqualInt32());
                case TypeCode.Int64: return _Int64 ?? (_Int64 = new EqualInt64());

                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new EqualInt16());
                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new EqualInt32());
                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new EqualInt64());

                case TypeCode.Single: return _Single ?? (_Single = new EqualSingle());
                case TypeCode.Double: return _Double ?? (_Double = new EqualDouble());

                case TypeCode.Object:
                    if (!type.IsValueType()) {
                        return _Reference ?? (_Reference = new EqualReference());
                    }
                    // TODO: Nullable<T>
                    throw new NotImplementedException();

                default:
                    throw new NotImplementedException();
            }
        }