Exemple #1
0
        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();
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
    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));
 }
Exemple #6
0
 internal static RealtimeManager.FetchInvitationsResponse FromPointer(IntPtr pointer)
 {
     if (PInvokeUtilities.IsNull(pointer))
     {
         return((RealtimeManager.FetchInvitationsResponse)null);
     }
     return(new RealtimeManager.FetchInvitationsResponse(pointer));
 }
Exemple #7
0
 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);
     }
 }
Exemple #9
0
 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));
 }
Exemple #11
0
 internal static FetchResponse FromPointer(IntPtr selfPointer)
 {
     if (PInvokeUtilities.IsNull(selfPointer))
     {
         return(null);
     }
     return(new FetchResponse(selfPointer));
 }
Exemple #12
0
 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);
     }
 }
Exemple #14
0
 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));
 }
Exemple #17
0
 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);
Exemple #20
0
 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);
 }
Exemple #21
0
 internal static bool IsNull(HandleRef reference)
 {
     return(PInvokeUtilities.IsNull(HandleRef.ToIntPtr(reference)));
 }
 protected bool IsDisposed()
 {
     return(PInvokeUtilities.IsNull(mSelfPointer));
 }