public Object Get(Type type, Int32 stackPos = -1) { if (Marshals.ContainsKey(type)) { ILuaTypeMarshal marshal = Marshals[type]; return(Convert.ChangeType(marshal.Get(this, stackPos), type)); } return(null); }
public void Push(Object obj, Type type) { if (Marshals.ContainsKey(type)) { ILuaTypeMarshal marshal = Marshals[type] as ILuaTypeMarshal; marshal.Push(this, obj); } else { ILuaTypeMarshal backupMarshal = Marshals.Where(kv => type.IsCastableTo(kv.Key)).Select(kv => kv.Value).FirstOrDefault(); if (backupMarshal != null) { backupMarshal.Push(this, obj); } } }
public static void RegisterMarshal(Type t, ILuaTypeMarshal marshal) => Marshals.Add(t, marshal);