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