FromInt32() публичный статический Метод

Creates a Number value from a int value
Requires an active script context.
public static FromInt32 ( int value ) : IeJsValue
value int The value to be converted
Результат IeJsValue
Пример #1
0
        /// <summary>
        /// Makes a mapping of value from the host type to a script type
        /// </summary>
        /// <param name="value">The source value</param>
        /// <returns>The mapped value</returns>
        private IeJsValue MapToScriptType(object value)
        {
            if (value == null)
            {
                return(IeJsValue.Null);
            }

            if (value is Undefined)
            {
                return(IeJsValue.Undefined);
            }

            var typeCode = value.GetType().GetTypeCode();

            switch (typeCode)
            {
            case TypeCode.Boolean:
                return((bool)value ? IeJsValue.True : IeJsValue.False);

            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
                return(IeJsValue.FromInt32(Convert.ToInt32(value)));

            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
                return(IeJsValue.FromDouble(Convert.ToDouble(value)));

            case TypeCode.Char:
            case TypeCode.String:
                return(IeJsValue.FromString((string)value));

            default:
#if NETSTANDARD1_3
                return(FromObject(value));
#else
                object processedValue = !TypeConverter.IsPrimitiveType(typeCode) ?
                                        new HostObject(value, _engineMode) : value;
                return(IeJsValue.FromObject(processedValue));
#endif
            }
        }