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 {
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
2021-08-30 18:41:35 +03:00
[UnsupportedOSPlatform ("ios9.0")]
#if IOS
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
2022-01-14 19:20:06 +03:00
#else
[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 {
[DllImport (Constants.AddressBookUILibrary)]
2021-03-04 18:22:24 +03:00
static extern IntPtr /* NSString */ ABCreateStringWithAddressDictionary ( IntPtr /* NSDictionary */ address , [ MarshalAs ( UnmanagedType . I1 ) ] bool addCountryName ) ;
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 ) ) ;
2016-04-21 15:30:02 +03:00
using ( NSString s = new NSString ( ABCreateStringWithAddressDictionary ( address . Handle , addCountryName ) ) )
return s . ToString ( ) ;
}
}
}