コード例 #1
0
 public void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
     if (contactProperty != null)
     {
         var value = contactProperty.GetNameMatchingValue();
         var key   = contactProperty.GetNameMatchingKey();
         if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(key))
         {
             this.message = $"{contactProperty.Contact.GetFormattedName()}'s {key} ({value}) was selected.";
         }
     }
 }
コード例 #2
0
        public static string GetNameMatchingKey(this CNContactProperty property)
        {
            switch (property.Key)
            {
            case "emailAddress":
                return("Email address");

            case "phoneNumber":
                return("Phone number");

            case "postalAddress":
                return("Postal address");

            default:
                return(null);
            }
        }
コード例 #3
0
        public static string GetNameMatchingLocalizedLabel(this CNContactProperty property)
        {
            var label = property?.Label;

            if (!string.IsNullOrEmpty(label))
            {
                var nativelabel = new NSString(label);
                switch (property.Label)
                {
                case "emailAddresses":
                    return(CNLabeledValue <NSString> .LocalizeLabel(nativelabel));

                case "phoneNumbers":
                    return(CNLabeledValue <NSString> .LocalizeLabel(nativelabel));

                case "postalAddresses":
                    return(CNLabeledValue <NSString> .LocalizeLabel(nativelabel));
                }
            }
            return(null);
        }
コード例 #4
0
        public static string GetNameMatchingValue(this CNContactProperty property)
        {
            switch (property.Key)
            {
            case "emailAddress":
                return(property.Value as NSString);

            case "phoneNumber":
                if (property.Value is CNPhoneNumber phoneNumber)
                {
                    return(phoneNumber.StringValue);
                }
                break;

            case "postalAddress":
                if (property.Value is CNPostalAddress postalAddress)
                {
                    return(postalAddress.GetFormattedPostalAddress());
                }
                break;
            }
            return(null);
        }
コード例 #5
0
 public void ContactPickerDidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
 }
コード例 #6
0
        public override void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
        {
            if (contactProperty != null)
            {
                var sections = new List <Section>();
                var section  = new Section {
                    Items = new List <string>()
                };

                var nameKey = contactProperty.GetNameMatchingKey();
                if (!string.IsNullOrEmpty(nameKey))
                {
                    section.Items.Add($"Contact: {contactProperty.Contact.GetFormattedName()}");
                    section.Items.Add($"Key: {nameKey}");
                }

                // Attempt to fetch the localized label of the property.
                var localizedLabel = contactProperty.GetNameMatchingLocalizedLabel();
                if (!string.IsNullOrEmpty(localizedLabel))
                {
                    section.Items.Add($"Label : {localizedLabel}");
                }

                // Attempt to fetch the value of the property.
                var value = contactProperty.GetNameMatchingValue();
                if (!string.IsNullOrEmpty(value))
                {
                    section.Items.Add($"Value: {value}");
                }

                sections.Add(section);
                this.callback(sections);
            }
        }
コード例 #7
0
 public override void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
     ContactPropertySelected?.Invoke(contactProperty);
 }
コード例 #8
0
 public override void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
     Console.WriteLine ("Selected Property: {0}", contactProperty);
 }
コード例 #9
0
		public void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
		{
			string message = $"Picked -> {contactProperty.Identifier}";
			Console.WriteLine(message);
		}
コード例 #10
0
 internal void RaiseContactPropertySelected(CNContactProperty property)
 {
     ContactPropertySelected?.Invoke(property);
 }
コード例 #11
0
 public override void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
     // Raise the contact property selected event
     RaiseContactPropertySelected(contactProperty);
 }
コード例 #12
0
        public void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
        {
            string message = $"Picked -> {contactProperty.Identifier}";

            Console.WriteLine(message);
        }
コード例 #13
0
 public override void DidSelectContactProperty(CNContactPickerViewController picker, CNContactProperty contactProperty)
 {
     Console.WriteLine("Selected Property: {0}", contactProperty);
 }
コード例 #14
0
 public bool ShouldPerformDefaultAction(CNContactViewController viewController, CNContactProperty property)
 {
     return(false);
 }