public static int GetIndex(IntPtr luaState) { var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName); var instanceIndex = new IntPtr(Marshal.ReadInt32(instancePointer)); return(instanceIndex.ToInt32()); }
private static int DeleteInstance(IntPtr luaState) { var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName); var instanceIndex = new IntPtr(Marshal.ReadInt32(instancePointer)); _instancesDict[instanceIndex.ToInt32()] = default(T); _instancesDict.Remove(instanceIndex.ToInt32()); return(0); }
public static T GetInstance(IntPtr luaState) { switch (_createPolicy) { case CreatePolicy.Factory: var instancePointer = XLLuaRuntime.luaL_checkudata(luaState, 1, _typeFullName); var instanceIndex = new IntPtr(Marshal.ReadInt32(instancePointer)); var instance = _instancesDict[instanceIndex.ToInt32()]; return(instance); case CreatePolicy.Singleton: return(_instance); default: return(default(T)); } }