示例#1
0
        private static void setValue(FieldInfo toInfo, string name, object obj, object value)
        {
            try
            {
                toInfo.SetValue(obj, value);
            }
            catch (Exception)
            {
                try
                {
                    if (toInfo.FieldType == typeof(BigInteger))
                    {
                        if (value is string && string.IsNullOrEmpty((string)value))
                        {
                            value = 0;
                        }

                        value = BigIntegerHelper.FromScientific(value.ToString());
                    }


                    value = Convert.ChangeType(value, toInfo.FieldType);
                    toInfo.SetValue(obj, value);
                }
                catch (Exception e)
                {
                    DebugX.Log(obj.ToString() + ":" + name + " 类型转换失败,需要为:" + toInfo.FieldType + " value:" + value + "\n" +
                               e.Message);
                }
            }
        }
示例#2
0
        public static float DivideFloat(BigInteger a, BigInteger b)
        {
            if (a == null || b == null)
            {
                return(0.0f);
            }
            BigInteger result    = (a * 100) / b;
            long       resultInt = BigIntegerHelper.ToInt64(result);

            return(resultInt / 100.0f);
        }