Mono.CSharp.MetadataImporter.ImportParameterConstant C# (CSharp) Method

ImportParameterConstant() static private method

static private ImportParameterConstant ( object value ) : Constant
value object
return Constant
        static Constant ImportParameterConstant(object value)
        {
            //
            // Get type of underlying value as int constant can be used for object
            // parameter type. This is not allowed in C# but other languages can do that
            //
            switch (System.Type.GetTypeCode (value.GetType ())) {
            case TypeCode.Boolean:
                return new BoolConstant ((bool) value, Location.Null);
            case TypeCode.Byte:
                return new ByteConstant ((byte) value, Location.Null);
            case TypeCode.Char:
                return new CharConstant ((char) value, Location.Null);
            case TypeCode.Decimal:
                return new DecimalConstant ((decimal) value, Location.Null);
            case TypeCode.Double:
                return new DoubleConstant ((double) value, Location.Null);
            case TypeCode.Int16:
                return new ShortConstant ((short) value, Location.Null);
            case TypeCode.Int32:
                return new IntConstant ((int) value, Location.Null);
            case TypeCode.Int64:
                return new LongConstant ((long) value, Location.Null);
            case TypeCode.SByte:
                return new SByteConstant ((sbyte) value, Location.Null);
            case TypeCode.Single:
                return new FloatConstant ((float) value, Location.Null);
            case TypeCode.String:
                return new StringConstant ((string) value, Location.Null);
            case TypeCode.UInt16:
                return new UShortConstant ((ushort) value, Location.Null);
            case TypeCode.UInt32:
                return new UIntConstant ((uint) value, Location.Null);
            case TypeCode.UInt64:
                return new ULongConstant ((ulong) value, Location.Null);
            }

            throw new NotImplementedException (value.GetType ().ToString ());
        }