Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="zone"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void SaveRecordZone(
            CKRecordZone zone,
            Action <CKRecordZone, NSError> completionHandler)
        {
            if (zone == null)
            {
                throw new ArgumentNullException(nameof(zone));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            SaveRecordZoneCallbacks[completionHandlerCall] = new ExecutionContext <CKRecordZone, NSError>(completionHandler);

            CKDatabase_saveRecordZone_completionHandler(
                Handle,
                zone != null ? HandleRef.ToIntPtr(zone.Handle) : IntPtr.Zero,

                completionHandlerCall.id, SaveRecordZoneCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 2
0
        public CKRecord(
            string recordType,
            CKRecordID recordID
            )
        {
            if (recordType == null)
            {
                throw new ArgumentNullException(nameof(recordType));
            }
            if (recordID == null)
            {
                throw new ArgumentNullException(nameof(recordID));
            }

            IntPtr ptr = CKRecord_initWithRecordType_recordID(
                recordType,
                recordID != null ? HandleRef.ToIntPtr(recordID.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            Handle = new HandleRef(this, ptr);
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <param name="recordID"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void FetchRecordWithID(
            CKRecordID recordID,
            Action <CKRecord, NSError> completionHandler)
        {
            if (recordID == null)
            {
                throw new ArgumentNullException(nameof(recordID));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            FetchRecordWithIDCallbacks[completionHandlerCall] = new ExecutionContext <CKRecord, NSError>(completionHandler);

            CKDatabase_fetchRecordWithID_completionHandler(
                Handle,
                recordID != null ? HandleRef.ToIntPtr(recordID.Handle) : IntPtr.Zero,

                completionHandlerCall.id, FetchRecordWithIDCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// </summary>
        /// <param name="metadata"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void AcceptShareMetadata(
            CKShareMetadata metadata,
            Action <CKShare, NSError> completionHandler)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            AcceptShareMetadataCallbacks[completionHandlerCall] = new ExecutionContext <CKShare, NSError>(completionHandler);

            CKContainer_acceptShareMetadata_completionHandler(
                Handle,
                metadata != null ? HandleRef.ToIntPtr(metadata.Handle) : IntPtr.Zero,

                completionHandlerCall.id, AcceptShareMetadataCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="zoneID"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void DeleteRecordZoneWithID(
            CKRecordZoneID zoneID,
            Action <CKRecordZoneID, NSError> completionHandler)
        {
            if (zoneID == null)
            {
                throw new ArgumentNullException(nameof(zoneID));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            DeleteRecordZoneWithIDCallbacks[completionHandlerCall] = completionHandler;

            CKDatabase_deleteRecordZoneWithID_completionHandler(
                Handle,
                zoneID != null ? HandleRef.ToIntPtr(zoneID.Handle) : IntPtr.Zero,

                completionHandlerCall.id, DeleteRecordZoneWithIDCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// </summary>
        /// <param name="subscription"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void SaveSubscription(
            CKSubscription subscription,
            Action <CKSubscription, NSError> completionHandler)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            SaveSubscriptionCallbacks[completionHandlerCall] = completionHandler;

            CKDatabase_saveSubscription_completionHandler(
                Handle,
                subscription != null ? HandleRef.ToIntPtr(subscription.Handle) : IntPtr.Zero,

                completionHandlerCall.id, SaveSubscriptionCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// </summary>
        /// <param name="query"></param><param name="zoneID"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void PerformQuery(
            CKQuery query,
            CKRecordZoneID zoneID,
            Action <CKRecord[], NSError> completionHandler)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }



            var completionHandlerCall = new InvocationRecord(Handle);

            PerformQueryCallbacks[completionHandlerCall] = completionHandler;

            CKDatabase_performQuery_inZoneWithID_completionHandler(
                Handle,
                query != null ? HandleRef.ToIntPtr(query.Handle) : IntPtr.Zero,

                zoneID != null ? HandleRef.ToIntPtr(zoneID.Handle) : IntPtr.Zero,

                completionHandlerCall.id, PerformQueryCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// </summary>
        /// <param name="url"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void FetchShareMetadataWithURL(
            NSURL url,
            Action <CKShareMetadata, NSError> completionHandler)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            FetchShareMetadataWithURLCallbacks[completionHandlerCall] = new ExecutionContext <CKShareMetadata, NSError>(completionHandler);

            CKContainer_fetchShareMetadataWithURL_completionHandler(
                Handle,
                url != null ? HandleRef.ToIntPtr(url.Handle) : IntPtr.Zero,

                completionHandlerCall.id, FetchShareMetadataWithURLCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="flag"></param><param name="url"></param><param name="destinationURL"></param><param name="error"></param>
        /// <returns>val</returns>
        public bool SetUbiquitousItemAtURL(
            bool flag,
            NSURL url,
            NSURL destinationURL,
            out NSError error)
        {
            IntPtr errorPtr;

            var val = NSFileManager_setUbiquitous_itemAtURL_destinationURL_error(
                Handle,
                flag,
                url != null ? HandleRef.ToIntPtr(url.Handle) : IntPtr.Zero,
                destinationURL != null ? HandleRef.ToIntPtr(destinationURL.Handle) : IntPtr.Zero,
                out errorPtr,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            error = errorPtr == IntPtr.Zero ? null : new NSError(errorPtr);

            return(val);
        }
Esempio n. 10
0
        public CKQuerySubscription(
            string recordType,
            NSPredicate predicate,
            CKQuerySubscriptionOptions querySubscriptionOptions
            )
        {
            if (recordType == null)
            {
                throw new ArgumentNullException(nameof(recordType));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            IntPtr ptr = CKQuerySubscription_initWithRecordType_predicate_options(
                recordType,
                predicate != null ? HandleRef.ToIntPtr(predicate.Handle) : IntPtr.Zero,
                (long)querySubscriptionOptions,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            Handle = new HandleRef(this, ptr);
        }
Esempio n. 11
0
        /// <summary>
        /// </summary>
        /// <param name="userRecordID"></param><param name="completionHandler"></param>
        /// <returns>void</returns>
        public void FetchShareParticipantWithUserRecordID(
            CKRecordID userRecordID,
            Action <CKShareParticipant, NSError> completionHandler)
        {
            if (userRecordID == null)
            {
                throw new ArgumentNullException(nameof(userRecordID));
            }


            var completionHandlerCall = new InvocationRecord(Handle);

            FetchShareParticipantWithUserRecordIDCallbacks[completionHandlerCall] = new ExecutionContext <CKShareParticipant, NSError>(completionHandler);

            CKContainer_fetchShareParticipantWithUserRecordID_completionHandler(
                Handle,
                userRecordID != null ? HandleRef.ToIntPtr(userRecordID.Handle) : IntPtr.Zero,

                completionHandlerCall.id, FetchShareParticipantWithUserRecordIDCallback,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 12
0
 internal System.IntPtr GetNativeWindowHandler()
 {
     System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
     if (NDalicPINVOKE.SWIGPendingException.Pending)
     {
         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
 private void InitControls()
 {
     PopulateWindowsHandlers();
     if (HandleRef.ToIntPtr(_hOKButton) != IntPtr.Zero)
     {
         NativeMethods.EnableWindow(_hOKButton, _EnableOkBtn);
         NativeMethods.SetWindowText(_hOKButton, _OKCaption);
     }
 }
Esempio n. 14
0
        public void Ctor_Wrapper_Handle(object wrapper, int handle)
        {
            var handleRef = new HandleRef(wrapper, (IntPtr)handle);

            Assert.Same(wrapper, handleRef.Wrapper);
            Assert.Equal((IntPtr)handle, handleRef.Handle);
            Assert.Equal((IntPtr)handle, (IntPtr)handleRef);
            Assert.Equal((IntPtr)handle, HandleRef.ToIntPtr(handleRef));
        }
Esempio n. 15
0
        public void Ctor_Default()
        {
            var handleRef = new HandleRef();

            Assert.Null(handleRef.Wrapper);
            Assert.Equal(IntPtr.Zero, handleRef.Handle);
            Assert.Equal(IntPtr.Zero, (IntPtr)handleRef);
            Assert.Equal(IntPtr.Zero, HandleRef.ToIntPtr(handleRef));
        }
Esempio n. 16
0
        internal GameServices Build(PlatformConfiguration configRef)
        {
            IntPtr selfPointer = Builder.GameServices_Builder_Create(SelfPtr(), HandleRef.ToIntPtr(configRef.AsHandle()));

            if (selfPointer.Equals(IntPtr.Zero))
            {
                throw new InvalidOperationException("There was an error creating a GameServices object. Check for log errors from GamesNativeSDK");
            }
            return(new GameServices(selfPointer));
        }
Esempio n. 17
0
    public static void Main()
    {
        Console.WriteLine("Accessors Test!");
        Accessors sut = new Accessors();

        sut.PropPrim = 18;
        if (sut.PropPrim != 18)
        {
            throw new System.InvalidOperationException("PropPrim");
        }
        sut.PropEnum = Accessors.MyEnum.VAL_1;
        if (sut.PropEnum != Accessors.MyEnum.VAL_1)
        {
            throw new System.InvalidOperationException("PropEnum");
        }
        sut.PropPtr = sut;
        if (sut.PropPtr.PropPrim != 18)
        {
            throw new System.InvalidOperationException("PropPtr");
        }
        sut.PropString = "gato";
        if (sut.PropString.CompareTo("gato") != 0)
        {
            throw new System.InvalidOperationException("PropString");
        }

        /// Unsafe
        int num23 = 23;
        int result;

        unsafe {
            //int* v = &num23;
            IntPtr ip = new IntPtr(&num23);
            sut.PropPrimitivePtr = new SWIGTYPE_p_unsigned_char(ip, false);

            int *ret = (int *)HandleRef.ToIntPtr(SWIGTYPE_p_unsigned_char.getCPtr(sut.PropPrimitivePtr)).ToPointer();
            result = *ret;
        }
        if (result != 23)
        {
            throw new System.InvalidOperationException("PropPrimitivePtr");
        }

        /// Static
        Accessors.StaticPropPtr = new Other();
        if (Accessors.StaticPropPtr == null)
        {
            throw new System.InvalidOperationException("PropPtr");
        }
        Accessors.StaticPropString = "gato";
        if (Accessors.StaticPropString.CompareTo("gato") != 0)
        {
            throw new System.InvalidOperationException("PropString");
        }
    }
Esempio n. 18
0
        public void Properties()
        {
            var obj       = new object();
            var ptr       = new IntPtr(1337);
            var handleRef = new HandleRef(obj, ptr);

            Assert.Equal(ptr, (IntPtr)handleRef);
            Assert.Equal(ptr, HandleRef.ToIntPtr(handleRef));
            Assert.Equal(ptr, handleRef.Handle);
            Assert.Same(obj, handleRef.Wrapper);
        }
Esempio n. 19
0
    /// <summary>
    /// システムメニューの「移動」の表示を設定する
    /// </summary>
    public static void SetMoveMenuEnabled(IWin32Window owner, bool enable)
    {
        HandleRef windowHandle = new HandleRef(owner, owner.Handle);

        // システムメニューを取得する
        IntPtr sysMenu = GetSystemMenu(HandleRef.ToIntPtr(windowHandle), false);

        // システムメニューの「移動」の表示を設定する
        EnableMenuItem(sysMenu, SC_MOVE, MF_BYCOMMAND | (enable ? MF_ENABLED : MF_DISABLED | MF_GRAYED));

        // システムメニューを再描画する
        DrawMenuBar(sysMenu);
    }
Esempio n. 20
0
        /// <summary>
        /// </summary>
        /// <param name="key"></param>
        /// <returns>val</returns>
        public void RemoveDidChangeExternallyNotificationObserver(Unsubscriber unsubscriber)
        {
            IntPtr exceptionPtr = IntPtr.Zero;

            RemoveNSUbiquitousKeyValueStoreDidChangeExternallyNotificationObserver(unsubscriber.Handle, ref exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            NSUbiquitousKeyValueStoreDidChangeExternallyNotificationHandlers.Remove(HandleRef.ToIntPtr(unsubscriber.Handle));
        }
Esempio n. 21
0
        /// <summary>
        /// </summary>
        /// <param name="parentRecordID"></param>
        /// <returns>void</returns>
        public void SetParentReferenceFromRecordID(
            CKRecordID parentRecordID)
        {
            CKRecord_setParentReferenceFromRecordID(
                Handle,
                parentRecordID != null ? HandleRef.ToIntPtr(parentRecordID.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 22
0
        public static void RemoveAccountChangedNotificationObserver(Unsubscriber unsubscriber)
        {
            IntPtr exceptionPtr = IntPtr.Zero;

            RemoveCKAccountChangedNotificationObserver(unsubscriber.Handle, ref exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            AccountChangedNotificationHandlers.Remove(HandleRef.ToIntPtr(unsubscriber.Handle));
        }
        public static void RemoveIdentityDidChangeObserver(Unsubscriber unsubscriber)
        {
            IntPtr exceptionPtr = IntPtr.Zero;

            RemoveNSUbiquityIdentityDidChangeNotificationObserver(unsubscriber.Handle, ref exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            IdentityDidChangeHandlers.Remove(HandleRef.ToIntPtr(unsubscriber.Handle));
        }
Esempio n. 24
0
        /// <summary>
        /// </summary>
        /// <param name="participant"></param>
        /// <returns>void</returns>
        public void RemoveParticipant(
            CKShareParticipant participant)
        {
            CKShare_removeParticipant(
                Handle,
                participant != null ? HandleRef.ToIntPtr(participant.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }
        }
Esempio n. 25
0
        internal GameServices Build(PlatformConfiguration configRef)
        {
            IntPtr pointer = C.GameServices_Builder_Create(SelfPtr(),
                                                           HandleRef.ToIntPtr(configRef.AsHandle()));

            if (pointer.Equals(IntPtr.Zero))
            {
                // TODO(hsakai): For now, explode noisily. In the actual plugin, this probably
                // should result in something besides an exception.
                throw new System.InvalidOperationException("There was an error creating a " +
                                                           "GameServices object. Check for log errors from GamesNativeSDK");
            }

            return(new GameServices(pointer));
        }
Esempio n. 26
0
        public CKShare(
            CKRecord rootRecord
            )
        {
            IntPtr ptr = CKShare_initWithRootRecord(
                rootRecord != null ? HandleRef.ToIntPtr(rootRecord.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            Handle = new HandleRef(this, ptr);
        }
        /// <summary>
        /// </summary>
        /// <param name="url"></param>
        /// <returns>val</returns>
        public bool IsUbiquitousItemAtURL(
            NSURL url)
        {
            var val = NSFileManager_isUbiquitousItemAtURL(
                Handle,
                url != null ? HandleRef.ToIntPtr(url.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            return(val);
        }
Esempio n. 28
0
        public CKShare(
            NSCoder aDecoder
            )
        {
            IntPtr ptr = CKShare_initWithCoder(
                aDecoder != null ? HandleRef.ToIntPtr(aDecoder.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            Handle = new HandleRef(this, ptr);
        }
Esempio n. 29
0
        public void appIdleHandle(Process p)
        {
            var hwndPanel = panel1.Handle;
            WindowInteropHelper helper = new WindowInteropHelper(Window.GetWindow(this));

            Thread.Sleep(1000);
            SetParent(p.MainWindowHandle, hwndPanel);   //将窗体以子窗体嵌入
            HandleRef hanref = new HandleRef(this, p.MainWindowHandle);

            //SetWindowLong(HandleRef.ToIntPtr(hanref), GWL_STYLE, WS_VISIBLE);    //需要使用user32.dll,这SetWindowLong(HandleRef.ToIntPtr(hanref), GWL_STYLE, WS_VISIBLE);    //需要使用user32.dll,这样就去除了unity3D画面windows边界,并且使得画面能够显示出来样就去除了unity3D画面windows边界,并且使得画面能够显示出来
            MoveWindow(p.MainWindowHandle, 0, 0, (int)this.panel1.Width, (int)this.panel1.Height, true); //(int)this.PContainer.Left, (int)this.PContainer.Top, (int)this.PContainer.Width, (int)this.PContainer.Height, true);
            SetWindowLong(HandleRef.ToIntPtr(hanref), GWL_STYLE, WS_VISIBLE);                            //需要使用user32.dll,这样就去除了unity3D画面windows边界,并且使得画面能够显示出来
            Thread.Sleep(1000);
            MoveWindow(p.MainWindowHandle, 0, 0, (int)this.panel1.Width, (int)this.panel1.Height, true);
            SetWindowLong(HandleRef.ToIntPtr(hanref), GWL_STYLE, WS_VISIBLE);
        }
        public CKFetchDatabaseChangesOperation(
            CKServerChangeToken previousServerChangeToken
            )
        {
            IntPtr ptr = CKFetchDatabaseChangesOperation_initWithPreviousServerChangeToken(
                previousServerChangeToken != null ? HandleRef.ToIntPtr(previousServerChangeToken.Handle) : IntPtr.Zero,
                out IntPtr exceptionPtr);

            if (exceptionPtr != IntPtr.Zero)
            {
                var nativeException = new NSException(exceptionPtr);
                throw new CloudKitException(nativeException, nativeException.Reason);
            }

            Handle = new HandleRef(this, ptr);
        }