private object LuaToNumber(object v, Nullable <int> iBase = null) { if (v == null) { return(null); } else { switch (Type.GetTypeCode(v.GetType())) { case TypeCode.String: if (iBase.HasValue) { return(Lua.RtParseNumber(null, (string)v, 0, iBase.Value, lua.FloatType == LuaFloatType.Double, false)); } else { return(Lua.RtParseNumber((string)v, lua.FloatType == LuaFloatType.Double, 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: case TypeCode.Single: case TypeCode.Double: case TypeCode.Decimal: return(v); case TypeCode.Boolean: return((bool)v ? 1 : 0); default: return(null); } } } // func LuaToNumber
} // func ParseNumber /// <summary>Parses a string to a lua number.</summary> /// <param name="sNumber">String representation of the number.</param> /// <param name="iBase">Base fore the number</param> /// <returns></returns> public object ParseNumber(string sNumber, int iBase) { return(Lua.RtParseNumber(null, sNumber, 0, iBase, FloatType == LuaFloatType.Double, false)); } // func ParseNumber
} // func GetFloatType /// <summary>Parses a string to a lua number.</summary> /// <param name="sNumber">String representation of the number.</param> /// <returns></returns> public object ParseNumber(string sNumber) { return(Lua.RtParseNumber(sNumber, FloatType == LuaFloatType.Double, false)); } // func ParseNumber