| | | 1 | | using Neo.IronLua; |
| | | 2 | | |
| | | 3 | | namespace Itinero.Profiles.Lua; |
| | | 4 | | |
| | | 5 | | internal static class LuaTableExtensions |
| | | 6 | | { |
| | | 7 | | internal static double? GetDouble(this LuaTable table, string key) |
| | 13 | 8 | | { |
| | 13 | 9 | | var obj = table[key]; |
| | 13 | 10 | | if (obj == null) |
| | 6 | 11 | | { |
| | 6 | 12 | | return null; |
| | | 13 | | } |
| | | 14 | | |
| | 7 | 15 | | if (obj is double d) |
| | 3 | 16 | | { |
| | 3 | 17 | | return d; |
| | | 18 | | } |
| | | 19 | | |
| | 4 | 20 | | if (obj is int i) |
| | 4 | 21 | | { |
| | 4 | 22 | | return i; |
| | | 23 | | } |
| | | 24 | | |
| | 0 | 25 | | return (double)obj; |
| | 13 | 26 | | } |
| | | 27 | | |
| | | 28 | | internal static bool? GetBoolean(this LuaTable table, string key) |
| | 3 | 29 | | { |
| | 3 | 30 | | var obj = table[key]; |
| | 3 | 31 | | if (obj == null) |
| | 3 | 32 | | { |
| | 3 | 33 | | return null; |
| | | 34 | | } |
| | | 35 | | |
| | 0 | 36 | | if (obj is bool b) |
| | 0 | 37 | | { |
| | 0 | 38 | | return b; |
| | | 39 | | } |
| | | 40 | | |
| | 0 | 41 | | return (bool)obj; |
| | 3 | 42 | | } |
| | | 43 | | } |