2016-04-21 15:30:02 +03:00
|
|
|
//
|
|
|
|
// ABAddressFormatting.cs:
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Sebastien Pouliot <sebastien@xamarin.com>
|
|
|
|
//
|
|
|
|
// Copyright (C) 2012 Xamarin Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2022-03-05 01:57:03 +03:00
|
|
|
#nullable enable
|
|
|
|
|
2016-04-21 15:30:02 +03:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2018-02-05 18:26:29 +03:00
|
|
|
using Foundation;
|
|
|
|
using ObjCRuntime;
|
2016-04-21 15:30:02 +03:00
|
|
|
|
2018-02-05 18:26:29 +03:00
|
|
|
namespace AddressBookUI {
|
2022-10-14 17:14:36 +03:00
|
|
|
|
2016-04-21 15:30:02 +03:00
|
|
|
// http://developer.apple.com/library/ios/#DOCUMENTATION/AddressBookUI/Reference/AddressBookUI_Functions/Reference/reference.html#//apple_ref/c/func/ABCreateStringWithAddressDictionary
|
2022-01-14 19:20:06 +03:00
|
|
|
#if NET
|
2022-12-22 14:40:04 +03:00
|
|
|
[SupportedOSPlatform ("ios")]
|
2022-09-20 20:47:49 +03:00
|
|
|
[ObsoletedOSPlatform ("ios9.0", "Use the 'Contacts' API instead.")]
|
2022-01-14 19:20:06 +03:00
|
|
|
#else
|
2022-10-14 17:14:36 +03:00
|
|
|
[Deprecated (PlatformName.iOS, 9, 0, message: "Use the 'Contacts' API instead.")]
|
2021-08-30 18:41:35 +03:00
|
|
|
#endif
|
2016-04-21 15:30:02 +03:00
|
|
|
static public class ABAddressFormatting {
|
2022-10-14 17:14:36 +03:00
|
|
|
|
2016-04-21 15:30:02 +03:00
|
|
|
[DllImport (Constants.AddressBookUILibrary)]
|
2021-03-04 18:22:24 +03:00
|
|
|
static extern IntPtr /* NSString */ ABCreateStringWithAddressDictionary (IntPtr /* NSDictionary */ address, [MarshalAs (UnmanagedType.I1)] bool addCountryName);
|
2022-10-14 17:14:36 +03:00
|
|
|
|
2016-04-21 15:30:02 +03:00
|
|
|
static public string ToString (NSDictionary address, bool addCountryName)
|
|
|
|
{
|
2022-03-05 01:57:03 +03:00
|
|
|
if (address is null)
|
|
|
|
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (address));
|
2022-10-14 17:14:36 +03:00
|
|
|
|
2016-04-21 15:30:02 +03:00
|
|
|
using (NSString s = new NSString (ABCreateStringWithAddressDictionary (address.Handle, addCountryName)))
|
|
|
|
return s.ToString ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|