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 NotEqualBoolean())); case TypeCode.SByte: return(_SByte ?? (_SByte = new NotEqualSByte())); case TypeCode.Byte: return(_Byte ?? (_Byte = new NotEqualByte())); case TypeCode.Char: return(_Char ?? (_Char = new NotEqualChar())); case TypeCode.Int16: return(_Int16 ?? (_Int16 = new NotEqualInt16())); case TypeCode.Int32: return(_Int32 ?? (_Int32 = new NotEqualInt32())); case TypeCode.Int64: return(_Int64 ?? (_Int64 = new NotEqualInt64())); case TypeCode.UInt16: return(_UInt16 ?? (_UInt16 = new NotEqualInt16())); case TypeCode.UInt32: return(_UInt32 ?? (_UInt32 = new NotEqualInt32())); case TypeCode.UInt64: return(_UInt64 ?? (_UInt64 = new NotEqualInt64())); case TypeCode.Single: return(_Single ?? (_Single = new NotEqualSingle())); case TypeCode.Double: return(_Double ?? (_Double = new NotEqualDouble())); case TypeCode.String: return(_String ?? (_Double = new NotEqualString())); case TypeCode.Object: if (!type.IsValueType()) { return(_Reference ?? (_Reference = new NotEqualReference())); } // TODO: Nullable<T> throw new NotImplementedException(); default: throw new NotImplementedException(); } }
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 NotEqualBoolean()); case TypeCode.SByte: return _SByte ?? (_SByte = new NotEqualSByte()); case TypeCode.Byte: return _Byte ?? (_Byte = new NotEqualByte()); case TypeCode.Char: return _Char ?? (_Char = new NotEqualChar()); case TypeCode.String: return _String ?? (_String = new NotEqualString()); case TypeCode.Int16: return _Int16 ?? (_Int16 = new NotEqualInt16()); case TypeCode.Int32: return _Int32 ?? (_Int32 = new NotEqualInt32()); case TypeCode.Int64: return _Int64 ?? (_Int64 = new NotEqualInt64()); case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new NotEqualInt16()); case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new NotEqualInt32()); case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new NotEqualInt64()); case TypeCode.Single: return _Single ?? (_Single = new NotEqualSingle()); case TypeCode.Double: return _Double ?? (_Double = new NotEqualDouble()); case TypeCode.Object: if (!type.IsValueType()) { return _Reference ?? (_Reference = new NotEqualReference()); } // TODO: Nullable<T> throw new NotImplementedException(); default: throw new NotImplementedException(); } }