public override void Reset()
 {
     intVariable = null;
     stringVariable = null;
     numberStyle = System.Globalization.NumberStyles.Any;
     everyFrame = false;
 }
        static StackObject *Parse_10(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Globalization.NumberStyles @style = (System.Globalization.NumberStyles) typeof(System.Globalization.NumberStyles).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @s = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = System.Int32.Parse(@s, @style);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
Ejemplo n.º 3
0
        public int Modificacion(Inmueble i)
        {
            int res = -1;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                System.Globalization.CultureInfo  provider = new System.Globalization.CultureInfo("es-AR");
                System.Globalization.NumberStyles style    = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowThousands;
                decimal number = decimal.Parse(i.Precio.ToString(), style, provider);
                string  sql    = $"UPDATE Inmueble SET Tipo='{i.Tipo}', Direccion='{i.Direccion}', Uso='{i.Uso}', Ambientes={i.Ambientes}, Disponible={i.Disponible}, Precio={number.ToString(System.Globalization.CultureInfo.InvariantCulture)}, IdPropietario={i.IdPropietario} " +
                                 $" WHERE IdInmueble = {i.IdInmueble}";
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = CommandType.Text;
                    connection.Open();
                    res = command.ExecuteNonQuery();
                    connection.Close();
                }
            }
            return(res);
        }
Ejemplo n.º 4
0
        public void TestDecimalString()
        {
            var fr = new RandomGenerator();

            for (var i = 0; i < 1000; ++i)
            {
                EDecimal ed = RandomObjects.RandomEDecimal(fr);
                if (!ed.IsFinite)
                {
                    continue;
                }
                decimal d;
                try {
                    System.Globalization.NumberStyles numstyles =
                        System.Globalization.NumberStyles.AllowExponent |
                        System.Globalization.NumberStyles.Number;
                    d = Decimal.Parse(
                        ed.ToString(),
                        numstyles,
                        System.Globalization.CultureInfo.InvariantCulture);
                    EDecimal ed3 = EDecimal.FromString(
                        ed.ToString(),
                        EContext.CliDecimal);
                    string msg = ed.ToString() + " (expanded: " +
                                 EDecimal.FromString(ed.ToString()) + ")";
                    TestCommon.CompareTestEqual(
                        (EDecimal)d,
                        ed3,
                        msg);
                } catch (OverflowException ex) {
                    EDecimal ed2 = EDecimal.FromString(
                        ed.ToString(),
                        EContext.CliDecimal);
                    Assert.IsTrue(
                        ed2.IsInfinity(),
                        ed.ToString(),
                        ex.ToString());
                }
            }
        }
Ejemplo n.º 5
0
        private void dataGridViewAi_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                object obj = dataGridViewAi[e.ColumnIndex, e.RowIndex].Value;

                if (obj == null)
                {
                    return;
                }

                string text = obj.ToString();

                // 設定値を取得
                int value;
                System.Globalization.CultureInfo  provider = System.Globalization.CultureInfo.CurrentCulture;
                System.Globalization.NumberStyles style    = checkBoxAiHex.Checked ?
                                                             System.Globalization.NumberStyles.HexNumber : System.Globalization.NumberStyles.Number;

                if (int.TryParse(text, style, provider, out value))
                {
                    // 16bit
                    if (checkBoxAiHex.Checked)
                    {
                        if (ushort.MinValue <= value && value <= ushort.MaxValue)
                        {
                            value -= 65536;
                        }
                    }

                    if (short.MinValue <= value && value <= short.MaxValue)
                    {
                        com.SetAi(e.RowIndex, value);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
    public void LoadMap()
    {
        //родительский gameobject всех плиток Tile
        GameObject go = new GameObject("TILE_ANCHOR");

        TILE_ANCHOR = go.transform;

        //загрузка спрайтов из mapTiles
        SPRITES = Resources.LoadAll <Sprite>(mapTiles.name); //изображение тайлов находится в папке Resourses, выгружаем спрайты из него

        //парсинг информации для карты
        string[] lines = mapData.text.Split('\n');                                              // разбиваем содержимое файла на строки
        H = lines.Length;                                                                       // число строк - H
        string[] tileNums = lines[0].Split(' ');                                                // первая строчка разбивается на подстроки по пробелу, каждый 2-значн. 16-ичн. код сохраняется в отдельный элемент
        W = tileNums.Length;                                                                    // количество элементов

        System.Globalization.NumberStyles hexNum = System.Globalization.NumberStyles.HexNumber; // Для преобразования строк с 2-зн. 16-ичн. кодами в целые числа нужно сделать такой финт ушами
        //сохраняем инфу для карты в двумерный массив для ускорения доступа
        MAP = new int[W, H];
        for (int j = 0; j < H; j++)
        {
            tileNums = lines[j].Split(' ');
            for (int i = 0; i < W; i++)
            {
                if (tileNums[i] == "..")
                {
                    MAP[i, j] = 0;                      // ".." == пустота
                }
                else
                {
                    MAP[i, j] = int.Parse(tileNums[i], hexNum);
                }
                CheckTileSwaps(i, j);
            }
        }
        print("Parsed " + SPRITES.Length + " sprites."); // !!! ТОЧКА ОСТАНОВА для проверки значений в полях MAP и SPRITES
        print("Map size: " + W + " wide by " + H + " high");

        ShowMap();
    }
Ejemplo n.º 7
0
        //based on UnifyWiki  http://wiki.unity3d.com/index.php?title=HexConverter
        static Color32 HexToColor(string hex)
        {
            const System.Globalization.NumberStyles HexStyle = System.Globalization.NumberStyles.HexNumber;

            if (hex.Length < 6)
            {
                return(Color.magenta);
            }

            hex = hex.Replace("#", "");
            byte r = byte.Parse(hex.Substring(0, 2), HexStyle);
            byte g = byte.Parse(hex.Substring(2, 2), HexStyle);
            byte b = byte.Parse(hex.Substring(4, 2), HexStyle);
            byte a = 0xFF;

            if (hex.Length == 8)
            {
                a = byte.Parse(hex.Substring(6, 2), HexStyle);
            }

            return(new Color32(r, g, b, a));
        }
Ejemplo n.º 8
0
        /// <summary>Creates a ResourceTypeIdentifier instance from a string which may represent a Known Win32 Resource Type, a number, or a string id (in that order)</summary>
        /// <param name="shortStyle">Set to True to allow short-style identifiers like "icon" or "bmp" (for IconDirectory and Bitmap respectively) to be parsed as being Known Win32 types as opposed to their full names</param>
        public static ResourceIdentifier CreateFromString(String ambiguousString)
        {
            if (ambiguousString == null)
            {
                throw new ArgumentNullException("ambiguousString");
            }
            if (ambiguousString.Length == 0)
            {
                throw new ArgumentOutOfRangeException("ambiguousString", "Length must be greater than 0");
            }

            // if the string starts with " then it always refers to a string version
            // if it starts with "" then ignore the first

            if (ambiguousString.StartsWith("\"\"", StringComparison.Ordinal))
            {
                // if ambiguousString == '""0"' then result is '"0"'
                return(new ResourceIdentifier(ambiguousString.Substring(1)));
            }
            else if (ambiguousString.StartsWith("\"", StringComparison.Ordinal))
            {
                // if ambiguousString == '"0"' then result is '0' (e.g. in msonsext.dll )
                return(new ResourceIdentifier(ambiguousString.Substring(1)));
            }

            String ambiguousStringUpper = ambiguousString.ToUpperInvariant();

            // is the string a number?

            Int32        number2;
            NumberStyles numStyle = ambiguousStringUpper.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? NumberStyles.HexNumber : NumberStyles.Integer;

            if (Int32.TryParse(ambiguousStringUpper, numStyle, Cult.InvariantCulture, out number2))
            {
                return(new ResourceIdentifier(new IntPtr(number2)));
            }

            return(new ResourceIdentifier(ambiguousString));
        }
Ejemplo n.º 9
0
        public bool Read(string file, FileShare fs            = FileShare.None, bool commadelimit = true, Action <int, Row> rowoutput = null,
                         System.Globalization.NumberStyles ns = System.Globalization.NumberStyles.None, // if to allow thousands seperator etc
                         string noncommacountry = "sv"                                                  // for finwen, space is the default thousands.
                         )
        {
            if (!File.Exists(file))
            {
                return(false);
            }

            try
            {
                using (Stream s = File.Open(file, FileMode.Open, FileAccess.Read, fs))
                {
                    return(Read(s, commadelimit, rowoutput, ns, noncommacountry));
                }
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        static StackObject *Parse_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.IFormatProvider provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Globalization.NumberStyles style = (System.Globalization.NumberStyles) typeof(System.Globalization.NumberStyles).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String s = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = System.Int64.Parse(s, style, provider);

            __ret->ObjectType      = ObjectTypes.Long;
            *(long *)&__ret->Value = result_of_this_method;
            return(__ret + 1);
        }
Ejemplo n.º 11
0
        static internal bool ParseLiteral(string strVal, out UInt32 ii)
        {
            UInt32 multiplier = 1;

            System.Globalization.NumberStyles baseNum = System.Globalization.NumberStyles.Integer;

            if (strVal.Length > 2)
            {
                if (strVal.StartsWith("0x"))
                {
                    strVal  = strVal.Substring(2);
                    baseNum = System.Globalization.NumberStyles.HexNumber;
                }
            }

            /*else if (strVal.StartsWith("0b"))
             * {
             *      strVal = strVal.Substring(2);
             *      baseNum = System.Globalization.NumberStyles.HexNumber;
             * }*/// @TODO binary and octal literals UGH C# WHY

            if (strVal[strVal.Length - 1] == 'M')
            {
                strVal     = strVal.Substring(0, strVal.Length - 1);
                multiplier = 1024 * 1024;
            }

            if (UInt32.TryParse(strVal, baseNum,
                                System.Globalization.CultureInfo.CurrentCulture, out ii))
            {
                ii *= multiplier;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
 public static bool GetReal(string sVal, ref double dValue)
 {
     try
     {
         sVal = sVal.Replace(",", ".").Trim();
         if (sVal.Length > 0)
         {
             double dV = 0.0;
             System.Globalization.NumberStyles style   = System.Globalization.NumberStyles.Number;
             System.Globalization.CultureInfo  culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
             if (double.TryParse(sVal, style, culture, out dV))
             {
                 dValue = dV;
                 return(true);
             }
         }
     }
     catch (Exception ee)
     {
         WriteErrorLog(ee);
     }
     return(false);
 }
Ejemplo n.º 13
0
        public static decimal StringToDecimal(string p_strVal,
                                              System.Globalization.NumberStyles style,
                                              System.IFormatProvider provider,
                                              bool p_ConsiderAllStringAsPercent)
        {
            bool l_IsPercentString = IsPercentString(p_strVal, provider);

            if (l_IsPercentString)
            {
                return(decimal.Parse(p_strVal.Replace("%", ""), style, provider) / 100.0M);
            }
            else
            {
                if (p_ConsiderAllStringAsPercent)
                {
                    return(decimal.Parse(p_strVal, style, provider) / 100.0M);
                }
                else
                {
                    return(decimal.Parse(p_strVal, style, provider));
                }
            }
        }
Ejemplo n.º 14
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            System.Globalization.NumberStyles style   = System.Globalization.NumberStyles.Number | System.Globalization.NumberStyles.AllowCurrencySymbol;
            System.Globalization.CultureInfo  culture = System.Globalization.CultureInfo.CreateSpecificCulture("es-AR");
            if (!float.TryParse(mtxtGanacias.Text, style, culture, out float ganancias))
            {
                MessageBox.Show("Las ganacias deben ser un numero flotante");
                return;
            }
            if (!Object.ReferenceEquals(empresa, null))
            {
                empresa.Ganancias   = ganancias;
                empresa.RazonSocial = txtRazonSocial.Text;
                empresa.Direccion   = txtDireccion.Text;
            }
            else
            {
                empresa = new Empresa(txtRazonSocial.Text, txtDireccion.Text, ganancias);
            }
            frmEmpleado frm = new frmEmpleado();

            frm.Show();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Reads a <see cref="V3"/> value from an XML element's x, y, z attributes.
        /// </summary>
        internal static V3 GetV3(this XmlElement node)
        {
            System.Globalization.NumberStyles s = System.Globalization.NumberStyles.Float;
            System.IFormatProvider            f = System.Globalization.NumberFormatInfo.InvariantInfo;
            float x = 0;

            if (!(float.TryParse(node.GetAttribute("x"), s, f, out x) || float.TryParse(node.GetAttribute("X"), s, f, out x) || float.TryParse(node.GetAttribute("u"), s, f, out x) || float.TryParse(node.GetAttribute("U"), s, f, out x)))
            {
            }
            float y = 0;

            if (!(float.TryParse(node.GetAttribute("y"), s, f, out y) || float.TryParse(node.GetAttribute("Y"), s, f, out y) || float.TryParse(node.GetAttribute("v"), s, f, out y) || float.TryParse(node.GetAttribute("V"), s, f, out y)))
            {
            }
            float z = 0;

            if (!float.TryParse(node.GetAttribute("z"), out z))
            {
                float.TryParse(node.GetAttribute("Z"), out z);
            }

            return(new V3(x, y, z));
        }
        // reads a line from the file
        private bool ReadLineFromFile()
        {
            if (fileReader == null)
            {
                return(false);
            }

            // read a line
            sPlayLine = fileReader.ReadLine();
            if (sPlayLine == null)
            {
                return(false);
            }

            System.Globalization.CultureInfo  invCulture = System.Globalization.CultureInfo.InvariantCulture;
            System.Globalization.NumberStyles numFloat   = System.Globalization.NumberStyles.Float;

            // extract the unity time and the body frame
            char[]   delimiters = { '|' };
            string[] sLineParts = sPlayLine.Split(delimiters);

            if (sLineParts.Length >= 2)
            {
                float.TryParse(sLineParts[0], numFloat, invCulture, out fPlayTime);
                sPlayLine = sLineParts[1];
                fCurrentFrame++;

                if (infoText != null)
                {
                    infoText.text = string.Format("Playing @ {0:F3}s., frame {1}.", fPlayTime, fCurrentFrame);
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 17
0
        public static bool TryParse(string input, System.Globalization.NumberStyles styles, IFormatProvider prov, out Vector3 ret)
        {
            var m = vec_reg.Match(input);
            var x = m.Groups["X"].Value;
            var y = m.Groups["Y"].Value;
            var z = m.Groups["Z"].Value;

            ret = new Vector3();
            if (float.TryParse(x, styles, prov, out ret.x))
            {
                if (float.TryParse(y, styles, prov, out ret.y))
                {
                    return(float.TryParse(z, styles, prov, out ret.z));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        private EvaluatedExpression GetLongLiteral(string value)
        {
            Contract.Requires <ArgumentNullException>(value != null, "value");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(value));
            Contract.Ensures(Contract.Result <EvaluatedExpression>() != null);

            string       parseValue   = value;
            NumberStyles numberStyles = NumberStyles.None;

            if (parseValue.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
            {
                numberStyles |= NumberStyles.AllowHexSpecifier;
                parseValue    = parseValue.Substring(2);
            }

            long longValue;

            if (!long.TryParse(parseValue, numberStyles, CultureInfo.InvariantCulture, out longValue))
            {
                throw new FormatException();
            }

            return(new EvaluatedExpression(value, value, _stackFrame.GetVirtualMachine().GetMirrorOf(longValue), false));
        }
Ejemplo n.º 19
0
    static int TryParse(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(LuaInterface.LuaOut <byte>)))
            {
                string arg0 = ToLua.ToString(L, 1);
                byte   arg1;
                bool   o = System.Byte.TryParse(arg0, out arg1);
                LuaDLL.lua_pushboolean(L, o);
                LuaDLL.lua_pushnumber(L, arg1);
                return(2);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(System.Globalization.NumberStyles), typeof(System.IFormatProvider), typeof(LuaInterface.LuaOut <byte>)))
            {
                string arg0 = ToLua.ToString(L, 1);
                System.Globalization.NumberStyles arg1 = (System.Globalization.NumberStyles)ToLua.ToObject(L, 2);
                System.IFormatProvider            arg2 = (System.IFormatProvider)ToLua.ToObject(L, 3);
                byte arg3;
                bool o = System.Byte.TryParse(arg0, arg1, arg2, out arg3);
                LuaDLL.lua_pushboolean(L, o);
                LuaDLL.lua_pushnumber(L, arg3);
                return(2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Byte.TryParse"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 20
0
    static int TryParse(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                string arg0 = ToLua.CheckString(L, 1);
                int    arg1;
                bool   o = System.Int32.TryParse(arg0, out arg1);
                LuaDLL.lua_pushboolean(L, o);
                LuaDLL.lua_pushinteger(L, arg1);
                return(2);
            }
            else if (count == 4)
            {
                string arg0 = ToLua.CheckString(L, 1);
                System.Globalization.NumberStyles arg1 = (System.Globalization.NumberStyles)ToLua.CheckObject(L, 2, typeof(System.Globalization.NumberStyles));
                System.IFormatProvider            arg2 = (System.IFormatProvider)ToLua.CheckObject <System.IFormatProvider>(L, 3);
                int  arg3;
                bool o = System.Int32.TryParse(arg0, arg1, arg2, out arg3);
                LuaDLL.lua_pushboolean(L, o);
                LuaDLL.lua_pushinteger(L, arg3);
                return(2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Int32.TryParse"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 21
0
        /// <summary>Converts this value to a <c>decimal</c> under the Common
        /// Language Infrastructure (see
        /// <see cref='PeterO.Numbers.EDecimal'>"Forms of numbers"</see> ),
        /// using the half-even rounding mode.</summary>
        /// <returns>A <c>decimal</c> under the Common Language Infrastructure
        /// (usually a.NET Framework decimal).</returns>
        public decimal ToDecimal()
        {
            EDecimal extendedNumber = this;

            if (extendedNumber.IsInfinity() || extendedNumber.IsNaN())
            {
                throw new OverflowException("This object's value is out of range");
            }
            decimal ret;

            System.Globalization.NumberStyles
                ns = System.Globalization.NumberStyles.Number |
                     System.Globalization.NumberStyles.AllowExponent;
            if (
                Decimal.TryParse(
                    this.ToString(),
                    ns,
                    System.Globalization.CultureInfo.InvariantCulture,
                    out ret))
            {
                return(ret);
            }
            throw new OverflowException("This object's value is out of range");
        }
Ejemplo n.º 22
0
        // key = entered text in search (entry) widget

        // FALSE if the row matches, TRUE otherwise !!!
        protected static bool EqualFuncHex(string key, int content)
        {
            const System.Globalization.NumberStyles numberStyles = System.Globalization.NumberStyles.HexNumber;

            foreach (string prefix in AllowedHexPrefixes)
            {
                int index = key.IndexOf(prefix, StringComparison.InvariantCulture);
                if (index >= 0)
                {
                    key = key.Substring(index + prefix.Length);
                    break;
                }
            }
            int parsed;

            if (int.TryParse(key, numberStyles, System.Globalization.NumberFormatInfo.InvariantInfo, out parsed))
            {
                return(parsed != content);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 23
0
        static StackObject *TryParse_14(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Int64 result = *(long *)&ptr_of_this_method->Value;
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.IFormatProvider provider = (System.IFormatProvider) typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Globalization.NumberStyles style = (System.Globalization.NumberStyles) typeof(System.Globalization.NumberStyles).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            System.String s = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = System.Int64.TryParse(s, style, provider, out result);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var ___dst = *(StackObject **)&ptr_of_this_method->Value;
                ___dst->ObjectType      = ObjectTypes.Long;
                *(long *)&___dst->Value = result;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = result;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.GetField(ptr_of_this_method->ValueLow).SetValue(___obj, result);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = result;
                }
                else
                {
                    ((CLRType)t).GetField(ptr_of_this_method->ValueLow).SetValue(null, result);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Int64[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = result;
            }
            break;
            }

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Ejemplo n.º 24
0
 /// <summary>Converts the string representation of a number to a half-precision floating-point equivalent.</summary>
 /// <param name="s">String representation of the number to convert.</param>
 /// <param name="style">Specifies the format of s.</param>
 /// <param name="provider">Culture-specific formatting information.</param>
 /// <returns>A new Half instance.</returns>
 public static Half Parse(string s, System.Globalization.NumberStyles style, IFormatProvider provider)
 {
     return((Half)Single.Parse(s, style, provider));
 }
Ejemplo n.º 25
0
        public static byte Parse(string s, System.Globalization.NumberStyles style, IFormatProvider provider)
        {
            Contract.Ensures(System.Runtime.CompilerServices.RuntimeHelpers.OffsetToStringData == 8);

            return(default(byte));
        }
Ejemplo n.º 26
0
        public static bool TryParse(string s, System.Globalization.NumberStyles style, IFormatProvider provider, out byte result)
        {
            result = default(byte);

            return(default(bool));
        }
 public static float ToSingle(string value, System.Globalization.NumberStyles style)
 {
     return(System.Convert.ToSingle(ToDouble(value, style)));
 }
 public static decimal ToDecimal(string value, System.Globalization.NumberStyles style)
 {
     return(System.Convert.ToDecimal(ToDouble(value, style)));
 }
 public static double ToDouble(string value, System.Globalization.NumberStyles style)
 {
     return(ToDouble(value, style, null));
 }
    /// <summary>
    /// System.Converts any string to a number with no errors.
    /// </summary>
    /// <param name="value"></param>
    /// <param name="style"></param>
    /// <param name="provider"></param>
    /// <returns></returns>
    /// <remarks>
    /// TODO: I would also like to possibly include support for other number system bases. At least binary and octal.
    /// </remarks>
    public static double ToDouble(string value, System.Globalization.NumberStyles style, System.IFormatProvider provider)
    {
        if (string.IsNullOrEmpty(value))
        {
            return(0d);
        }

        style = style & System.Globalization.NumberStyles.Any;
        double dbl = 0;

        if (double.TryParse(value, style, provider, out dbl))
        {
            return(dbl);
        }
        else
        {
            //test hex
            int  i;
            bool isNeg = false;
            for (i = 0; i < value.Length; i++)
            {
                if (value[i] == ' ' || value[i] == '+')
                {
                    continue;
                }
                if (value[i] == '-')
                {
                    isNeg = !isNeg;
                    continue;
                }
                break;
            }

            if (i < value.Length - 1 &&
                (
                    (value[i] == '#') ||
                    (value[i] == '0' && (value[i + 1] == 'x' || value[i + 1] == 'X')) ||
                    (value[i] == '&' && (value[i + 1] == 'h' || value[i + 1] == 'H'))
                ))
            {
                //is hex
                style = (style & System.Globalization.NumberStyles.HexNumber) | System.Globalization.NumberStyles.AllowHexSpecifier;

                if (value[i] == '#')
                {
                    i++;
                }
                else
                {
                    i += 2;
                }
                int j = value.IndexOf('.', i);

                if (j >= 0)
                {
                    long lng = 0;
                    long.TryParse(value.Substring(i, j - i), style, provider, out lng);

                    if (isNeg)
                    {
                        lng = -lng;
                    }

                    long   flng   = 0;
                    string sfract = value.Substring(j + 1).Trim();
                    long.TryParse(sfract, style, provider, out flng);
                    return(System.Convert.ToDouble(lng) + System.Convert.ToDouble(flng) / System.Math.Pow(16d, sfract.Length));
                }
                else
                {
                    string num = value.Substring(i);
                    long   l;
                    if (long.TryParse(num, style, provider, out l))
                    {
                        return(System.Convert.ToDouble(l));
                    }
                    else
                    {
                        return(0d);
                    }
                }
            }
            else
            {
                return(0d);
            }
        }


        ////################
        ////OLD garbage heavy version

        //if (value == null) return 0d;
        //value = value.Trim();
        //if (string.IsNullOrEmpty(value)) return 0d;

        //#if UNITY_WEBPLAYER
        //			Match m = Regex.Match(value, RX_ISHEX, RegexOptions.IgnoreCase);
        //#else
        //            Match m = Regex.Match(value, RX_ISHEX, RegexOptions.IgnoreCase | RegexOptions.Compiled);
        //#endif

        //if (m.Success)
        //{
        //    long lng = 0;
        //    style = (style & System.Globalization.NumberStyles.HexNumber) | System.Globalization.NumberStyles.AllowHexSpecifier;
        //    long.TryParse(m.Groups["num"].Value, style, provider, out lng);

        //    if (m.Groups["sign"].Value == "-")
        //        lng = -lng;

        //    if (m.Groups["fractional"].Success)
        //    {
        //        long flng = 0;
        //        string sfract = m.Groups["fractional"].Value.Substring(1);
        //        long.TryParse(sfract, style, provider, out flng);
        //        return System.Convert.ToDouble(lng) + System.Convert.ToDouble(flng) / System.Math.Pow(16d, sfract.Length);
        //    }
        //    else
        //    {
        //        return System.Convert.ToDouble(lng);
        //    }

        //}
        //else
        //{
        //    style = style & System.Globalization.NumberStyles.Any;
        //    double dbl = 0;
        //    double.TryParse(value, style, provider, out dbl);
        //    return dbl;

        //}
    }
 public static int ToInt(string value, System.Globalization.NumberStyles style)
 {
     return(ToInt(ToDouble(value, style)));
 }