Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 6
0
 internal static RealtimeManager.FetchInvitationsResponse FromPointer(IntPtr pointer)
 {
     if (PInvokeUtilities.IsNull(pointer))
     {
         return((RealtimeManager.FetchInvitationsResponse)null);
     }
     return(new RealtimeManager.FetchInvitationsResponse(pointer));
 }
Ejemplo n.º 7
0
 internal static MultiplayerParticipant FromPointer(IntPtr pointer)
 {
     if (PInvokeUtilities.IsNull(pointer))
     {
         return(null);
     }
     return(new MultiplayerParticipant(pointer));
 }
Ejemplo n.º 8
0
 private void Dispose(bool fromFinalizer)
 {
     if (!PInvokeUtilities.IsNull(mSelfPointer))
     {
         CallDispose(mSelfPointer);
         mSelfPointer = new HandleRef(this, IntPtr.Zero);
     }
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 11
0
 internal static FetchResponse FromPointer(IntPtr selfPointer)
 {
     if (PInvokeUtilities.IsNull(selfPointer))
     {
         return(null);
     }
     return(new FetchResponse(selfPointer));
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 14
0
 internal static HandleRef CheckNonNull(HandleRef reference)
 {
     if (PInvokeUtilities.IsNull(reference))
     {
         throw new InvalidOperationException();
     }
     return(reference);
 }
Ejemplo n.º 15
0
 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));
 }
Ejemplo n.º 17
0
 internal static NativeTurnBasedMatch FromPointer(IntPtr selfPointer)
 {
     if (PInvokeUtilities.IsNull(selfPointer))
     {
         return((NativeTurnBasedMatch)null);
     }
     return(new NativeTurnBasedMatch(selfPointer));
 }
Ejemplo n.º 18
0
        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);
Ejemplo n.º 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);
 }
Ejemplo n.º 21
0
 internal static bool IsNull(HandleRef reference)
 {
     return(PInvokeUtilities.IsNull(HandleRef.ToIntPtr(reference)));
 }
Ejemplo n.º 22
0
 protected bool IsDisposed()
 {
     return(PInvokeUtilities.IsNull(mSelfPointer));
 }