Ejemplo n.º 1
0
        /// <summary>
        /// Fetches a unified contact for the specified contact identifier.
        /// </summary>
        /// <returns>The contact with identifier.</returns>
        /// <param name="identifier">Identifier.</param>
        /// <param name="keys">Keys.</param>
        /// <param name="error">Error.</param>
        public CNContact UnifiedContactWithIdentifier(NSString identifier, NSArray <NSString> keys, out NSError error)
        {
            Util.NullArgumentTest(identifier);
            Util.NullArgumentTest(keys);

            IntPtr errorPtr   = new IntPtr();
            var    contactPtr = C.CNContactStore_unifiedContactWithIdentifier(
                SelfPtr(),
                identifier.ToPointer(),
                keys.ToPointer(),
                ref errorPtr);

            error = null;
            if (PInvokeUtil.IsNotNull(errorPtr))
            {
                error = new NSError(errorPtr);
                CFFunctions.CFRelease(errorPtr);
            }

            CNContact contact = null;

            if (PInvokeUtil.IsNotNull(contactPtr))
            {
                contact = new CNContact(contactPtr);
                CFFunctions.CFRelease(contactPtr);
            }

            return(contact);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the contact name, formatted with the specified formatter.
        /// </summary>
        /// <returns>The from contact.</returns>
        /// <param name="contact">Contact.</param>
        /// <param name="style">Style.</param>
        public static NSString StringFromContact(CNContact contact, CNContactFormatterStyle style)
        {
            if (contact == null)
            {
                return(null);
            }

            NSString str = null;
            var      ptr = C.CNContactFormatter_stringFromContact(contact.ToPointer(), style);

            if (PInvokeUtil.IsNotNull(ptr))
            {
                str = new NSString(ptr);
                CFFunctions.CFRelease(ptr);
            }
            return(str);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the delimiter to use between name components.
        /// </summary>
        /// <returns>The for contact.</returns>
        /// <param name="contact">Contact.</param>
        public static NSString DelimiterForContact(CNContact contact)
        {
            if (contact == null)
            {
                return(null);
            }

            NSString str = null;
            var      ptr = C.CNContactFormatter_delimiterForContact(contact.ToPointer());

            if (PInvokeUtil.IsNotNull(ptr))
            {
                str = new NSString(ptr);
                CFFunctions.CFRelease(ptr);
            }
            return(str);
        }
Ejemplo n.º 4
0
        private static void InternalEnumerateContactsBlock(/* CNContact */ IntPtr contact, out bool stop, IntPtr secondaryCallback)
        {
            if (PInvokeUtil.IsNull(secondaryCallback))
            {
                stop = true;
                return;
            }

            CNContact ct = PInvokeUtil.IsNotNull(contact) ? new CNContact(contact) : null;

            // Invoke consumer callback.
            stop = PInvokeCallbackUtil.PerformInternalFunction <CNContact, bool>(
                "CNContactStore#InternalEnumerateContactsBlock",
                PInvokeCallbackUtil.Type.Permanent, // make sure the callback can be called repeatedly
                ct,
                secondaryCallback);

            // Release callback handle if stopping.
            if (stop)
            {
                PInvokeCallbackUtil.UnpinCallbackHandle(secondaryCallback);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns the display name order.
 /// </summary>
 /// <returns>The order for contact.</returns>
 /// <param name="contact">Contact.</param>
 public static CNContactDisplayNameOrder NameOrderForContact(CNContact contact)
 {
     return(contact == null ? CNContactDisplayNameOrder.CNContactDisplayNameOrderUserDefault : C.CNContactFormatter_nameOrderForContact(contact.ToPointer()));
 }