コード例 #1
0
ファイル: Utilities.cs プロジェクト: artemy0/Quiz
        public static CNMutableContact ToCNMutableContact(this Contact contact)
        {
            if (contact == null)
            {
                return(null);
            }

            CNMutableContact nativeContact = new CNMutableContact();

            if (contact.FirstName != null)
            {
                nativeContact.GivenName = NSString.StringWithUTF8String(contact.FirstName);
            }

            if (contact.MiddleName != null)
            {
                nativeContact.MiddleName = NSString.StringWithUTF8String(contact.MiddleName);
            }

            if (contact.LastName != null)
            {
                nativeContact.FamilyName = NSString.StringWithUTF8String(contact.LastName);
            }

            if (contact.Company != null)
            {
                nativeContact.OrganizationName = NSString.StringWithUTF8String(contact.Company);
            }


            if (contact.Birthday != null)
            {
                nativeContact.Birthday = contact.Birthday.Value.ToNSDateComponents();
            }

            nativeContact.EmailAddresses = ToCNCotactEmails(contact.Emails);
            nativeContact.PhoneNumbers   = ToCNContactPhoneNumbers(contact.PhoneNumbers);

            if (contact.Photo != null)
            {
                byte[] rawData = TextureUtilities.EncodeAsByteArray(contact.Photo, ImageFormat.PNG);
                nativeContact.ImageData = NSData.DataWithBytes(rawData, (uint)rawData.Length);
            }

            return(nativeContact);
        }