private static T IntPtrToCallback <T>(IntPtr handle, bool unpinHandle) where T : class { if (PInvokeUtilities.IsNull(handle)) { return(null); } var gcHandle = GCHandle.FromIntPtr(handle); try { return((T)gcHandle.Target); } catch (System.InvalidCastException e) { Logger.e("GC Handle pointed to unexpected type: " + gcHandle.Target.ToString() + ". Expected " + typeof(T)); throw e; } finally { if (unpinHandle) { gcHandle.Free(); } } }
private static T IntPtrToCallback <T>(IntPtr handle, bool unpinHandle) where T : class { if (!PInvokeUtilities.IsNull(handle)) { GCHandle gCHandle = GCHandle.FromIntPtr(handle); try { return((T)gCHandle.Target); IL_002b: T result; return(result); } catch (InvalidCastException ex) { Logger.e("GC Handle pointed to unexpected type: " + gCHandle.Target.ToString() + ". Expected " + typeof(T)); throw ex; IL_006f: T result; return(result); } finally { if (unpinHandle) { gCHandle.Free(); } } } return((T)null); }
internal static MultiplayerInvitation FromPointer(IntPtr selfPointer) { if (PInvokeUtilities.IsNull(selfPointer)) { return null; } return new MultiplayerInvitation(selfPointer); }
internal static RoomInboxUIResponse FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return(null); } return(new RoomInboxUIResponse(pointer)); }
internal static FetchInvitationsResponse FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return(null); } return(new FetchInvitationsResponse(pointer)); }
internal static RealtimeManager.FetchInvitationsResponse FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return((RealtimeManager.FetchInvitationsResponse)null); } return(new RealtimeManager.FetchInvitationsResponse(pointer)); }
internal static MultiplayerParticipant FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return(null); } return(new MultiplayerParticipant(pointer)); }
private void Dispose(bool fromFinalizer) { if (!PInvokeUtilities.IsNull(mSelfPointer)) { CallDispose(mSelfPointer); mSelfPointer = new HandleRef(this, IntPtr.Zero); } }
internal static PlayerSelectUIResponse FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return(null); } return(new PlayerSelectUIResponse(pointer)); }
internal static GooglePlayGames.Native.PInvoke.MultiplayerParticipant FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return(null); } return(new GooglePlayGames.Native.PInvoke.MultiplayerParticipant(pointer)); }
internal static FetchResponse FromPointer(IntPtr selfPointer) { if (PInvokeUtilities.IsNull(selfPointer)) { return(null); } return(new FetchResponse(selfPointer)); }
internal static PlayerManager.FetchSelfResponse FromPointer(IntPtr selfPointer) { if (PInvokeUtilities.IsNull(selfPointer)) { return((PlayerManager.FetchSelfResponse)null); } return(new PlayerManager.FetchSelfResponse(selfPointer)); }
private void Dispose(bool fromFinalizer) { if ((fromFinalizer || !_refs.ContainsKey(this.mSelfPointer)) && !PInvokeUtilities.IsNull(this.mSelfPointer)) { this.CallDispose(this.mSelfPointer); this.mSelfPointer = new HandleRef(this, IntPtr.Zero); } }
internal static HandleRef CheckNonNull(HandleRef reference) { if (PInvokeUtilities.IsNull(reference)) { throw new InvalidOperationException(); } return(reference); }
internal static TurnBasedManager.TurnBasedMatchesResponse FromPointer(IntPtr pointer) { if (PInvokeUtilities.IsNull(pointer)) { return((TurnBasedManager.TurnBasedMatchesResponse)null); } return(new TurnBasedManager.TurnBasedMatchesResponse(pointer)); }
internal static GooglePlayGames.Native.PInvoke.MultiplayerInvitation FromPointer(IntPtr selfPointer) { if (PInvokeUtilities.IsNull(selfPointer)) { return(null); } return(new GooglePlayGames.Native.PInvoke.MultiplayerInvitation(selfPointer)); }
internal static NativeTurnBasedMatch FromPointer(IntPtr selfPointer) { if (PInvokeUtilities.IsNull(selfPointer)) { return((NativeTurnBasedMatch)null); } return(new NativeTurnBasedMatch(selfPointer)); }
protected HandleRef SelfPtr() { if (PInvokeUtilities.IsNull(mSelfPointer)) { throw new InvalidOperationException( "Attempted to use object after it was cleaned up"); } return(mSelfPointer); }
protected bool IsDisposed() => PInvokeUtilities.IsNull(this.mSelfPointer);
private void Dispose(bool fromFinalizer) { if (!fromFinalizer && BaseReferenceHolder._refs.ContainsKey(this.mSelfPointer) || PInvokeUtilities.IsNull(this.mSelfPointer)) { return; } this.CallDispose(this.mSelfPointer); this.mSelfPointer = new HandleRef((object)this, IntPtr.Zero); }
internal static bool IsNull(HandleRef reference) { return(PInvokeUtilities.IsNull(HandleRef.ToIntPtr(reference))); }
protected bool IsDisposed() { return(PInvokeUtilities.IsNull(mSelfPointer)); }